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

GET/api/albums

Get all albums with optional filtering and pagination

POST/api/albums

Create a new album

GET/api/albums/:id

Get a specific album by ID

PUT/api/albums/:id

Update a specific album

DELETE/api/albums/:id

Delete a specific album

Query Parameters

userIdFilter albums by user ID
qSearch albums by title
limitNumber of albums to return (default: 10)
offsetNumber 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 album
  • title - The title/name of the album

Album Structure

id - Unique identifier for the album
userId - ID of the user who owns this album
title - Title or name of the album

Usage 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.

ResponseRift JSON API • Production-Ready, Zero-Config