Announcements

Help Wizard

Step 1

NEXT STEP

Web API artist top tracks endpoint is requiring "market" as mandatory request parameter

Web API artist top tracks endpoint is requiring "market" as mandatory request parameter

Even if in the documentation is explicitly mentioned that "If a valid user access token is specified in the request header, the country associated with the user account will take priority over this parameter" (see https://developer.spotify.com/documentation/web-api/reference/get-an-artists-top-tracks),

Given a valid user access token is specified,

when no "market" request parameter is provided,

then the get Artist's Top Tracks endpoint is returning error 400 "missing country parameter"

 

When the "market" request parameter is provided, then the API works fine.

 

Example of failing call:

 

curl \
    -i \
    -X GET \
    -H "Authorization: Bearer ${ACCESS_TOKEN}" \
    "https://api.spotify.com/v1/artists/${ARTIST_ID}/top-tracks"

 

 

Example of successful call:

 

curl \
    -i \
    -X GET \
    -H "Authorization: Bearer ${ACCESS_TOKEN}" \
    "https://api.spotify.com/v1/artists/${ARTIST_ID}/top-tracks?market=IT"

 

 

Other endpoints like "Search" (see: https://developer.spotify.com/documentation/web-api/reference/search) are correctly treating the "market" request parameter as optional

Reply
8 Replies

I definitely think there is a bug here with user markets. Not the exact same issue, but I'm trying to use the player/currently-playing endpoint, and without specifying any market, I'm getting weird behaviour where I receive the song name, but no `external_url` for it, because the song is available for the user's market, but not elsewhere (like the app's server region). 

Just noticed that a similar issue has already been reported in Dec '22 here: https://community.spotify.com/t5/Spotify-for-Developers/Get-Artists-Top-Tracks-Country-is-required/m...

I'm having this issue too

I have the same issue too. For now I solved it by adding the country parameter as such ?country=HN

 

My request endpoint ⬇️

 

fetch(
  'https://api.spotify.com/v1/artists/53XhwfbYqKCa1cC15pYq2q/top-tracks?country=HN'
  {
    headers: { Authorization: 'Bearer Z4ga...9lk' }
  }
)

 

 

 

When using Client Credentials, you'll need to specify the market. Else, you should use a Authorization Code flow.

Yes, currently I'm using the Authorization Code  method, and with this method I have the issue.

I don't see you using the authentication token in your code snipped.

My bad, I fixed it.

Suggested posts