Artists
Artist operations live under client.artists.
Methods
| Method | Returns | Description |
|---|---|---|
get(id) |
Artist |
Fetch an artist by Spotify ID |
get_several(ids) |
list[Artist] |
Fetch multiple artists (max 50 IDs) |
get_albums(id, include_groups=None, market=None, limit=None, offset=None) |
Page[SimplifiedAlbum] |
Fetch albums for an artist |
get_top_tracks(id, market=None) |
list[Track] |
Fetch an artist's top tracks |
Filtering album types
include_groups accepts the values album, single, appears_on, and
compilation. Pass a list to filter results.
Examples
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. |
get_several(ids)
async
Get multiple artists by IDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ids
|
list[str]
|
List of Spotify artist IDs. The Spotify API enforces a maximum of 50 IDs per request. |
required |
Returns:
| Type | Description |
|---|---|
list[Artist]
|
The requested artists. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If ids is empty. |
get_top_tracks(id, market=None)
async
Get an artist's top tracks for a given market.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The Spotify ID of the artist. |
required |
market
|
str | None
|
An ISO 3166-1 alpha-2 country code for the requested content. |
None
|
Returns:
| Type | Description |
|---|---|
list[Track]
|
The top tracks for the artist. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If id is empty. |