Spotify API returns a 404 not found when trying to fetch information for podcasts

Viewed 2861

Search if an answer is already available: No

1. Summarize the problem

Spotify introduced the ability to fetch information about podcasts and shows. Details here.

I am using the Python "requests" package to generate the request URL to get metrics like no_of_followers and so on (I am not sure if they're available for podcasts), so I tried getting metadata for a show.

The endpoint I used to get information about a show: GET https://api.spotify.com/v1/shows/{id}

headers = {
    "Authorization": f"Bearer {access_token}"
}
# endpoint used "https://api.spotify.com/v1/shows/{id}"

lookup_url = "https://api.spotify.com/v1/shows/3IM0lmZxpFAY7CwMuv9H4g" #"The Daily" podcast example
print(lookup_url)

r = requests.get(lookup_url, headers=headers)
print(r)
print(r.status_code)
print(r.json())

However I receive the following error response:

https://api.spotify.com/v1/shows/3IM0lmZxpFAY7CwMuv9H4g
<Response [404]>
404
{'error': {'status': 404, 'message': 'non existing id'}}

Questions at the end

2. Describe what you’ve tried

I tried pulling similar information using the search endpoint, there, I do get a valid response. Informative and as expected when searching for artists but the response data seems to be missing for the show I searched.

The endpoint I used to search for a show/artist: GET https://api.spotify.com/v1/search

Using the search endpoint to find information about a show/artist:

headers = {
    "Authorization": f"Bearer {access_token}"
}
endpoint = "https://api.spotify.com/v1/search"
data = urlencode({"q":"the daily","type":"show"})
# data = urlencode({"q":"drake","type":"artist"})

lookup_url = f"{endpoint}?{data}"
print(lookup_url)

r = requests.get(lookup_url, headers=headers)
print(r.status_code)
r.json()

Get the output for the show above as:

https://api.spotify.com/v1/search?q=the+daily&type=show
200
{'shows': {'href': 'https://api.spotify.com/v1/search?query=the+daily&type=show&offset=0&limit=20',
  'items': [None,
   None,
   None,
   None,
   None,
   None,
   None,
   None,
   None,
   None,
   None,
   None,
   None,
   None,
   None,
   None,
   None,
   None,
   None,
   None],
  'limit': 20,
  'next': 'https://api.spotify.com/v1/search?query=the+daily&type=show&offset=20&limit=20',
  'offset': 0,
  'previous': None,
  'total': 14755}}

If I try to search information for an artist, I get good results:

{'artists': {'href': 'https://api.spotify.com/v1/search?query=drake&type=artist&offset=0&limit=20',
  'items': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/3TVXtAsR1Inumwj472S9r4'},
    'followers': {'href': None, 'total': 48844145},
    'genres': ['canadian hip hop',
     'canadian pop',
     'hip hop',
     'pop rap',
     'rap',
     'toronto rap'],
    'href': 'https://api.spotify.com/v1/artists/3TVXtAsR1Inumwj472S9r4',
    'id': '3TVXtAsR1Inumwj472S9r4',
    'images': [{'height': 640,
      'url': 'https://i.scdn.co/image/60cfab40c6bb160a1906be45276829d430058005',
      'width': 640},
     {'height': 320,
      'url': 'https://i.scdn.co/image/5ea794cf832550943d5f8122afcf5f23ee9d85b7',
      'width': 320},
     {'height': 160,
      'url': 'https://i.scdn.co/image/8eaace74aaca82eaccde400bbcab2653b9cf86e1',
      'width': 160}],
    'name': 'Drake',
    'popularity': 98,
    'type': 'artist',
    'uri': 'spotify:artist:3TVXtAsR1Inumwj472S9r4'},
...output clipped for readability

3. Questions:

  1. Am I trying to pull information about a show incorrectly? I tried to use the search endpoint as mentioned below - which seems to work well for artists or tracks but not for shows.
  2. Is it possible to get metrics for a show - like followers, times_episodes_played and historic data?

Thanks for your help.

1 Answers

The Get a Show endpoint does seem to require the Market parameter to be supplied. In the section for that parameter although marked as optional it states:

If a country code is specified, only shows and episodes that are available in that market will be returned. 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. Note: If neither market or user country are provided, the content is considered unavailable for the client.

I also experienced issues with Podcast Shows and Episodes as also assumed as with other content you still get something when not supplying the Market parameter until I'd noticed that the following meant that without it you get nothing back, which is the problem you're experiencing,

If neither market or user country are provided, the content is considered unavailable for the client.

The documentation should really state that in this case, unlike for Songs etc the Market value is not optional, might be worth raising an issue on the Spotify for Developers forum

Related