Artist’s Albums
Search for albums of an artist using the Spotify ID of the artist.
We'll cover the following
Everyone has a favorite musician to whom they can listen endlessly. No matter which valley we wander off to, we do always end up circling back to the same artist. The Get Artist’s Albums endpoint can help us get our favorite artists’ albums.
The base URL https://api.spotify.com/v1/artists/{id}/albums
is used to get information about the albums of an artist. The path parameter {id}
is replaced with the artist’s ID whose albums we want to fetch. So if we’re going to fetch albums of an artist whose Spotify ID is sample_id
, the URL will be https://api.spotify.com/v1/artists/sample_id/albums
.
Request parameters
The information obtained by calling this endpoint can be filtered using the following query parameters.
Query parameter | Category | Type | Description |
| Optional | String | This can be used to filter the albums based on the artist's involvement in the album. The possible options are We can also assign multiple values to this parameter by separating those values using a comma(,). |
| Optional | Integer | This limits the number of items to be returned in the response. Its value ranges from |
| Optional | String | This is an ISO 3166-1 alpha-2 country code that we can use to fetch only the content available in a specific country. Some examples of country codes are |
| Optional | Integer | This parameter can be used to offset the first item we get in response. |
Fetch an artist's albums
Let's see how we can use this endpoint to get an artist's albums.
url = 'https://api.spotify.com/v1/artists/0TnOYISbd1XYRBk9myaseg/albums'#0TnOYISbd1XYRBk9myaseg is the ID of Pitbull a.k.a. Mr. Worldwideheaders = {'Content-Type': 'application/json','Authorization': 'Bearer {{CLIENT_CREDENTIALS_ACCESS_TOKEN}}'}response = requests.request("GET", url, headers=headers)print(json.dumps(response.json(), indent=4))
We can change the Spotify ID in line 1 to get albums of a different artist.
Note: We can use the Search for Item endpoint to get the Spotify ID of an artist.
We can also use some query parameters to filter the result. For example, try to fetch only the solo albums of an artist. For this, we need to append the following query parameter to URL
: ?include_groups=single
.
Response fields
Some important response fields are given in the table below:
Response field | Type | Description |
| String |
|
| Array | This is an external link which can be used to open this album on Spotify. |
| String | This is the release date of the album. |
| Array of objects | This array contains information about the artist. |
| Array of objects | This array contains cover images of the albums. |
| String | This is the Spotify ID of the album. |
| Array of objects | This array contains the ISO 3166-1 alpha-2 country code of the countries in which this album is available. |
| Integer | This tells us the total number of albums that we get in response. |