Spotipy: All queries return 404 "non existing id"

Created on 30 Jul 2020  路  8Comments  路  Source: plamere/spotipy

Describe the bug
Authenticated using client_id and client secret.
All endpoints return either 404 "non existing id" for single item queries like artist or empty lists of results for queries like search.

Your code

import spotipy
from spotipy.oauth2 import SpotifyClientCredentials

auth_manager = SpotifyClientCredentials()

sp = spotipy.Spotify(auth_manager=auth_manager)

uri = "https://open.spotify.com/show/71mvGXupfKcmO6jlmOJQTP"

show = sp.show(uri)
print(show)

Expected behavior
Should return a result for a valid query ID.

Output

HTTP Error for GET to https://api.spotify.com/v1/shows/71mvGXupfKcmO6jlmOJQTP returned 404 due to non existing id
Traceback (most recent call last):
  File "/home/ciferkey/PycharmProjects/pythonProject/venv/lib/python3.8/site-packages/spotipy/client.py", line 175, in _internal_call
    response.raise_for_status()
  File "/home/ciferkey/PycharmProjects/pythonProject/venv/lib/python3.8/site-packages/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.spotify.com/v1/shows/71mvGXupfKcmO6jlmOJQTP

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ciferkey/PycharmProjects/pythonProject/main.py", line 14, in <module>
    show = sp.show(url)
  File "/home/ciferkey/PycharmProjects/pythonProject/venv/lib/python3.8/site-packages/spotipy/client.py", line 384, in show
    return self._get("shows/" + trid, market=market)
  File "/home/ciferkey/PycharmProjects/pythonProject/venv/lib/python3.8/site-packages/spotipy/client.py", line 210, in _get
    return self._internal_call("GET", url, payload, kwargs)
  File "/home/ciferkey/PycharmProjects/pythonProject/venv/lib/python3.8/site-packages/spotipy/client.py", line 186, in _internal_call
    raise SpotifyException(
spotipy.exceptions.SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/shows/71mvGXupfKcmO6jlmOJQTP:
 non existing id

Environment:

  • OS: Linux, Manjaro 20
  • Python version: 3.8 Virtualenv
  • spotipy version: 2.13.0
  • IDE: PyCharm

Additional context
I've tried a variety of endpoints and they all seem to fail in the same way.

bug

All 8 comments

The resource is in URL form, not URI. Could you try e.g. spotify:show:71mvGXupfKcmO6jlmOJQTP?

Although, looking at the source it seems that URLs should be accepted too.

@felix-hilden Correct docs say you can supply "show_id - the show ID, URI or URL". The specific example is a URL but I've tried all they and they behaved the same way.

The plot thickens. Seems other users are having issues with the shows endpoint: https://community.spotify.com/t5/Spotify-for-Developers/Searching-for-podcasts-not-returning-results/m-p/4973209#M429

Another update based on on the forum.

This is definitely a problem with their API not conforming with the published documentation. The market param is documented as optional but it actually required.

This will not return a result: https://api.spotify.com/v1/shows/71mvGXupfKcmO6jlmOJQTP
But this will: https://api.spotify.com/v1/shows/71mvGXupfKcmO6jlmOJQTP?market=US

If we want this library to confirm with the docs I can close this issue and leave the code as is.
Alternatively the library could be updated to make the market parameter required. I'd be willing to make a PR with this quick fix and provide documentation for why it is needed.

It is needed with application tokens but not user tokens. I think the API is fine. Shows consider the market of a user or the specified market. See the doc for more info https://developer.spotify.com/documentation/web-api/reference/shows/get-a-show/

Though a notice about that to Spotipy documentation would be in order for sure.

Sounds good. I'll mark as closed then!

What was the simple answer to this in the end?

It didn't find the show because your user token is not from the US, so in your specific case you should specify it?

As the documentation suggests, either the market is inferred from a user's country, or it must be specified. Otherwise the show is treated as not available.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JessicaMartini212887 picture JessicaMartini212887  路  5Comments

gawaineo picture gawaineo  路  3Comments

StefanRickli picture StefanRickli  路  3Comments

Jeoffreybauvin picture Jeoffreybauvin  路  4Comments

fortyTwo102 picture fortyTwo102  路  4Comments