[GH-ISSUE #522] Search doesn't find some tracks #315

Closed
opened 2026-02-27 23:21:57 +03:00 by kerem · 3 comments
Owner

Originally created by @alpha23 on GitHub (Jun 29, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/522

I am searching for some tracks by a query which contains the artist and the track name. On some queries I don't get any results. When I use the same query via the Spotify console I will get the information i am searching for.

Here is the code I used to search the track with spotipy:

query = "Room Eleven Baby it's cold outside"
sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
results = sp.search(q=query, type="track", limit=20, offset=0)
print(results)

If I am using my own code to request the data from the Spotify API I get the same result like I get in the Spotify console:

query = "Room Eleven Baby it's cold outside"
token = "XYZ"
headers = {"Authorization": "Bearer {0}".format(token)}
response = requests.get("https://api.spotify.com/v1/search?q={0}&type=track".format(query), headers=headers)
data = response.json()
print(data)

Even if I use sp._get() with exactly the same URI like in the plain requests.get() call I cannot get any results:

data = sp._get("https://api.spotify.com/v1/search?q={0}&type=track".format(query))
print(data)

Is there something that is limited when I use SPOTIPY_CLIENT_ID and SPOTIPY_CLIENT_SECRET or is this just a bug?

Best regards
Mark Herzberg

Originally created by @alpha23 on GitHub (Jun 29, 2020). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/522 I am searching for some tracks by a query which contains the artist and the track name. On some queries I don't get any results. When I use the same query via the Spotify console I will get the information i am searching for. Here is the code I used to search the track with spotipy: `query = "Room Eleven Baby it's cold outside"` `sp = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())` `results = sp.search(q=query, type="track", limit=20, offset=0)` `print(results)` If I am using my own code to request the data from the Spotify API I get the same result like I get in the Spotify console: `query = "Room Eleven Baby it's cold outside"` `token = "XYZ"` `headers = {"Authorization": "Bearer {0}".format(token)}` `response = requests.get("https://api.spotify.com/v1/search?q={0}&type=track".format(query), headers=headers)` `data = response.json()` `print(data)` Even if I use sp._get() with exactly the same URI like in the plain requests.get() call I cannot get any results: `data = sp._get("https://api.spotify.com/v1/search?q={0}&type=track".format(query))` `print(data)` Is there something that is limited when I use SPOTIPY_CLIENT_ID and SPOTIPY_CLIENT_SECRET or is this just a bug? Best regards Mark Herzberg
kerem 2026-02-27 23:21:57 +03:00
Author
Owner

@GaryOma commented on GitHub (Jun 30, 2020):

I used to get the same problem few days ago. My fix was to change the market where you are making the search. By default I think it's using the "US" market, and for my searches I had to revert back to a "FR" market to get some results.

Insert the market here with the market parameter : results = sp.search(q=query, type="track", limit=20, offset=0, market="YOUR MARKET").

You can get the list of the syntax for the markets here : ISO 3166-1 alpha-2.

<!-- gh-comment-id:651855475 --> @GaryOma commented on GitHub (Jun 30, 2020): I used to get the same problem few days ago. My fix was to change the market where you are making the search. By default I think it's using the "US" market, and for my searches I had to revert back to a "FR" market to get some results. Insert the market here with the `market` parameter : `results = sp.search(q=query, type="track", limit=20, offset=0, market="YOUR MARKET")`. You can get the list of the _syntax_ for the markets here : [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
Author
Owner

@stephanebruckert commented on GitHub (Jun 30, 2020):

Let's add @GaryOma's answer to the FAQ

<!-- gh-comment-id:651919244 --> @stephanebruckert commented on GitHub (Jun 30, 2020): Let's add @GaryOma's answer to the FAQ
Author
Owner

@alpha23 commented on GitHub (Jun 30, 2020):

@GaryOma It seems like this really did the trick. Thank you for your advise!

<!-- gh-comment-id:652014975 --> @alpha23 commented on GitHub (Jun 30, 2020): @GaryOma It seems like this really did the trick. Thank you for your advise!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#315
No description provided.