Photos API
Manage photo galleries and albums with our comprehensive Photos API.
Overview
The Photos API provides endpoints for managing photo galleries, albums, and individual photos. Each photo belongs to an album and includes both full-size and thumbnail URLs.
Base URL: /api/photos
Endpoints
GET
/api/photos
Get all photos with optional filtering and pagination
POST
/api/photos
Create a new photo
GET
/api/photos/:id
Get a specific photo by ID
PUT
/api/photos/:id
Update a specific photo
DELETE
/api/photos/:id
Delete a specific photo
Query Parameters
albumId
Filter photos by album IDq
Search photos by titlelimit
Number of photos to return (default: 10)offset
Number of photos to skip (default: 0)Response Format
List Response
{
"total": 50,
"limit": 10,
"offset": 0,
"results": [
{
"id": 1,
"albumId": 1,
"title": "accusamus beatae ad facilis cum similique qui sunt",
"url": "https://picsum.photos/seed/photo1/600/400",
"thumbnailUrl": "https://picsum.photos/seed/photo1/150/150"
}
]
}
Single Photo Response
{
"id": 1,
"albumId": 1,
"title": "accusamus beatae ad facilis cum similique qui sunt",
"url": "https://picsum.photos/seed/photo1/600/400",
"thumbnailUrl": "https://picsum.photos/seed/photo1/150/150"
}
Required Fields
When creating or updating a photo, the following fields are required:
albumId
- The ID of the album this photo belongs totitle
- The title/description of the photourl
- The full-size image URLthumbnailUrl
- The thumbnail image URL
Photo Structure
id
- Unique identifier for the photoalbumId
- ID of the album containing this phototitle
- Title or description of the photourl
- Full-size image URL (typically 600x400)thumbnailUrl
- Thumbnail image URL (typically 150x150)Usage Examples
Get Photos by Album
// Get all photos from album 1
fetch('/api/photos?albumId=1')
.then(response => response.json())
.then(data => console.log(data.results));
Create New Photo
// Add a new photo to album 1
fetch('/api/photos', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
albumId: 1,
title: "My New Photo",
url: "https://example.com/photo.jpg",
thumbnailUrl: "https://example.com/thumb.jpg"
})
})
.then(response => response.json())
.then(data => console.log(data));
Search Photos
// Search photos by title
fetch('/api/photos?q=beatae&limit=5')
.then(response => response.json())
.then(data => console.log(data.results));
⚠️ Important Note
All data changes (POST, PUT, DELETE) are stored in memory and will be reset when the server restarts. This is a mock API designed for development and testing purposes.