Corsair
PluginsSpotify

Spotify Database Schema

Database entities and querying synced Spotify data

The Spotify plugin syncs music library data to your database for fast queries.

New to Corsair? Learn about database operations, data synchronization, and multi-tenancy.

Full Implementation: See the Spotify plugin source code.

Synced Entities

  • tracks - Track metadata
  • albums - Album metadata
  • artists - Artist metadata
  • playlists - Playlist metadata

Database API

const tracks = await corsair.spotify.db.tracks.search({
    data: { name: "Bohemian Rhapsody" },
});

Tracks

Schema

{
    id: string;            // Spotify track ID
    uri: string;           // Spotify URI
    name: string;
    duration_ms: number;
    explicit: boolean;
    popularity?: number;   // 0-100
    preview_url?: string;
    album_id: string;
    artist_ids: string[];
}

Querying Tracks

Search by name:

const tracks = await corsair.spotify.db.tracks.search({
    data: { name: "Bohemian Rhapsody" }, 
});

Albums

Schema

{
    id: string;
    uri: string;
    name: string;
    album_type: string;    // album | single | compilation
    release_date: string;
    total_tracks: number;
    artist_ids: string[];
    image_url?: string;
}

Artists

Schema

{
    id: string;
    uri: string;
    name: string;
    genres: string[];
    popularity?: number;   // 0-100
    followers?: number;
    image_url?: string;
}

Querying Artists

const artists = await corsair.spotify.db.artists.search({
    data: { name: "Queen" }, 
});

Playlists

Schema

{
    id: string;
    uri: string;
    name: string;
    description?: string;
    public: boolean;
    owner_id: string;
    total_tracks: number;
    image_url?: string;
}

Example: Multi-Tenancy Query

const tenant = corsair.withTenant("user-123");

const playlists = await tenant.spotify.db.playlists.search({
    data: { public: false }, 
});