Artist’s Albums

Search for albums of an artist using the Spotify ID of the artist.

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

include_groups

Optional

String

This can be used to filter the albums based on the artist's involvement in the album. The possible options are album, single, appear_on, compilation.

We can also assign multiple values to this parameter by separating those values using a comma(,).

limit

Optional

Integer

This limits the number of items to be returned in the response. Its value ranges from 0 to 50 and the default value is 20.

market

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 us for the United States, es for Spain, and fr for France. If we send an auth code access token in the request header, the user's country will take priority over the country specified in this parameter.

offset

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.

Press + to interact
url = 'https://api.spotify.com/v1/artists/0TnOYISbd1XYRBk9myaseg/albums'
#0TnOYISbd1XYRBk9myaseg is the ID of Pitbull a.k.a. Mr. Worldwide
headers = {
'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

name

String

name in the items array is the name of the album.

spotify

Array

This is an external link which can be used to open this album on Spotify.

release_date

String

This is the release date of the album.

artists

Array of objects

This array contains information about the artist.

images

Array of objects

This array contains cover images of the albums.

id

String

This is the Spotify ID of the album.

available_markets

Array of objects

This array contains the ISO 3166-1 alpha-2 country code of the countries in which this album is available.

total

Integer

This tells us the total number of albums that we get in response.