Bug in Search API: Always returning null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Country
Germany
Operating System
Windows 10
My Question or Issue
Hello fellow developers,
I'm currently experiencing an issue with the /search endpoint in the API. My ultimate goal is to obtain the Spotify IDs for songs listed in the listening history JSON files (which only contain title and artist).
When GETting the endpoint with the required parameters I always get an empty response with this payload:
{\n "tracks" : {\n "href" : "https://api.spotify.com/v1/search?query=artist%3AKendrick%2520Lamar%2Btrack%3Agood%2520kid&type=track&offset=0&limit=20",\n "items" : [ ],\n "limit" : 20,\n "next" : null,\n "offset" : 0,\n "previous" : null,\n "total" : 0\n }\n}
You can see the provided parameters in the URL, here are the required Auth headers for that request:
headers = {
"Authorization" : f"Bearer {access}",
"Accept" : "application/json",
"Content-Type" : "application/json"
}
The variable "access" is a valid access token acquired through the auth code flow, I have verified that it works through the get playlist items endpoint, which works flawlessly.
The same thing btw happens when using the official Spotify API console with a generated access token (see attached screenshot).
So in short, I'm reporting that the /search endpoint is not working for me, can others reproduce this?
My Python code:
def getSongId(access: str, title: str, artist: str):
url = "https://api.spotify.com/v1/"
endpoint = "search"
data = {
"q" : f"artist:{artist}+track:{title}",
"type" : ["track"]
}
headers = {
"Authorization" : f"Bearer {access}",
"Accept" : "application/json",
"Content-Type" : "application/json"
}
resp = requests.get(url=url+endpoint,params=data,headers=headers)
print(resp.content)
PS: would there be another way to programmatically obtain Spotify IDs for songs of whom only title and artist are known when the /search endpoint turns out to be broken?

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page