Albums API
Manage photo albums and collections with our comprehensive Albums API.
Overview
The Albums API provides endpoints for managing photo albums and collections. Each album belongs to a user and can contain multiple photos. This API works in conjunction with the Photos API to create complete photo gallery systems.
Base URL: /api/albums
Endpoints
/api/albums
Get all albums with optional filtering and pagination
/api/albums
Create a new album
/api/albums/:id
Get a specific album by ID
/api/albums/:id
Update a specific album
/api/albums/:id
Delete a specific album
Query Parameters
userId
Filter albums by user IDq
Search albums by titlelimit
Number of albums to return (default: 10)offset
Number of albums to skip (default: 0)Response Format
List Response
{
"total": 50,
"limit": 10,
"offset": 0,
"results": [
{
"id": 1,
"userId": 1,
"title": "quidem molestiae enim"
}
]
}
Single Album Response
{
"id": 1,
"userId": 1,
"title": "quidem molestiae enim"
}
Required Fields
When creating or updating an album, the following fields are required:
userId
- The ID of the user who owns this albumtitle
- The title/name of the album
Album Structure
id
- Unique identifier for the albumuserId
- ID of the user who owns this albumtitle
- Title or name of the albumUsage with Photos
Albums work together with the Photos API to create complete photo galleries:
- Create an album first using
/api/albums
- Add photos to the album using
/api/photos
with the album ID - Retrieve photos by album using
/api/photos?albumId=X
- Manage album metadata separately from photo content
Usage Examples
Get Albums by User
// Get all albums for user 1
fetch('/api/albums?userId=1')
.then(response => response.json())
.then(data => console.log(data.results));
Create New Album
// Create a new album for user 1
fetch('/api/albums', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
userId: 1,
title: "Vacation Photos 2025"
})
})
.then(response => response.json())
.then(data => console.log(data));
Search Albums
// Search albums by title
fetch('/api/albums?q=vacation&limit=5')
.then(response => response.json())
.then(data => console.log(data.results));
Get Photos from Album
// Get all photos from album 1
fetch('/api/photos?albumId=1')
.then(response => response.json())
.then(data => console.log(data.results));
Complete Workflow
// 1. Create album
const album = await fetch('/api/albums', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
userId: 1,
title: "My Photo Collection"
})
}).then(r => r.json());
// 2. Add photos to album
const photo = await fetch('/api/photos', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
albumId: album.id,
title: "First Photo",
url: "https://example.com/photo.jpg",
thumbnailUrl: "https://example.com/thumb.jpg"
})
}).then(r => r.json());
console.log('Album:', album);
console.log('Photo:', photo);
⚠️ 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.