Skip to content

Artists

Artist operations live under client.artists.

Methods

Method Returns Description
get(id) Artist Fetch an artist by Spotify ID
get_albums(id, include_groups=None, market=None, limit=None, offset=None) Page[SimplifiedAlbum] Fetch albums for an artist

Filtering album types

include_groups accepts the values album, single, appears_on, and compilation. Pass a list to filter results.

Examples

from spotify_sdk import SpotifyClient

with SpotifyClient(access_token="your-access-token") as client:
    artist = client.artists.get("3TVXtAsR1Inumwj472S9r4")
    albums = client.artists.get_albums(
        artist.id,
        include_groups=["album", "single"],
        limit=10,
    )
import asyncio
from spotify_sdk import AsyncSpotifyClient


async def main() -> None:
    async with AsyncSpotifyClient(access_token="your-access-token") as client:
        artist = await client.artists.get("3TVXtAsR1Inumwj472S9r4")
        albums = await client.artists.get_albums(
            artist.id,
            include_groups=["album", "single"],
            limit=10,
        )


asyncio.run(main())

API details

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

Bases: AsyncBaseService

Operations for Spotify artists.

get(id) async

Get an artist by ID.

Parameters:

Name Type Description Default
id str

The Spotify ID of the artist.

required

Returns:

Type Description
Artist

The requested artist.

Raises:

Type Description
ValueError

If id is empty.

get_albums(id, include_groups=None, market=None, limit=None, offset=None) async

Get an artist's albums.

Parameters:

Name Type Description Default
id str

The Spotify ID of the artist.

required
include_groups list[IncludeGroup] | None

A list of keywords to filter album types. Valid values: album, single, appears_on, compilation. If omitted, all types are returned.

None
market str | None

An ISO 3166-1 alpha-2 country code for the requested content.

None
limit int | None

Maximum number of albums to return (1-50, server-side default of 20).

None
offset int | None

Index of the first album to return (server-side default of 0).

None

Returns:

Type Description
Page[SimplifiedAlbum]

The albums for the requested artist.

Raises:

Type Description
ValueError

If id is empty or include_groups contains invalid values.