Skip to content

Tracks

Track operations live under client.tracks.

Methods

Method Returns Description
get(id, market=None) Track Fetch a track by Spotify ID
get_saved(limit=20, offset=0, market=None) Page[SavedTrack] Fetch current user's saved tracks

Required scopes

Spotify requires user-scoped access tokens for saved track access. Ensure your auth flow requests user-library-read when using get_saved.

Examples

from spotify_sdk import SpotifyClient

with SpotifyClient(access_token="your-access-token") as client:
    track = client.tracks.get("3n3Ppam7vgaVa1iaRUc9Lp")
    saved_tracks = client.tracks.get_saved(limit=10)
import asyncio
from spotify_sdk import AsyncSpotifyClient


async def main() -> None:
    async with AsyncSpotifyClient(access_token="your-access-token") as client:
        track = await client.tracks.get("3n3Ppam7vgaVa1iaRUc9Lp")
        saved_tracks = await client.tracks.get_saved(limit=10)


asyncio.run(main())

API details

The sync client mirrors these methods, minus the await keywords.

Bases: AsyncBaseService

Operations for Spotify tracks.

get(id, market=None) async

Get a track by ID.

Parameters:

Name Type Description Default
id str

The Spotify ID for the track.

required
market str | None

An ISO 3166-1 alpha-2 country code for track relinking.

None

Returns:

Type Description
Track

The requested track.

Raises:

Type Description
ValueError

If id is empty.

get_saved(limit=20, offset=0, market=None) async

Get tracks saved in the current user's library.

Parameters:

Name Type Description Default
limit int

Maximum number of tracks to return (1-50, default 20).

20
offset int

Index of the first track to return.

0
market str | None

An ISO 3166-1 alpha-2 country code.

None

Returns:

Type Description
Page[SavedTrack]

Paginated list of saved tracks.