I’m using Python requests to get some info from Spotify API, After some requests, I encountered the 429 error, which indicates that the request limit has been exceeded. It is written in the Spotify document that when you encounter this error, there is a Retry-After in the response header that you have to wait for that amount of time and request again, but the response header that I receive does not have such a thing.
here is the code:
url = f'https://api.spotify.com/v1/audio-features/{track_id}'
res = requests.get(url, headers=self.headers)
if res.ok:
return res.json()
if res.status_code == 429:
print("------------- 429 ----------------")
print(res.headers)
return None
here is the response header:
{
"content-type": "application/json; charset=utf-8",
"cache-control": "private, max-age=0",
"access-control-allow-origin": "*",
"access-control-allow-headers": "Accept, App-Platform, Authorization, Content-Type, Origin, Retry-After, Spotify-App-Version, X-Cloud-Trace-Context, client-token, content-access-token",
"access-control-allow-methods": "GET, POST, OPTIONS, PUT, DELETE, PATCH",
"access-control-allow-credentials": "true",
"access-control-max-age": "604800",
"content-encoding": "gzip",
"strict-transport-security": "max-age=31536000",
"x-content-type-options": "nosniff",
"date": "Mon, 22 Jul 2024 11:51:11 GMT",
"server": "envoy",
"Via": "HTTP/2 edgeproxy, 1.1 google",
"Alt-Svc": "h3=":443"; ma=2592000,h3-29=":443"; ma=2592000",
"Transfer-Encoding": "chunked"
}