Receiving the 429 error when making requests to the artist endpoint, the 'Retry-After' header is there, but this is not the case with the audio-features or audio-analysis endpoints. Here is my code:
def get_audio_analysis(track_id):
try:
url = 'https://api.spotify.com/v1/audio-analysis/'
headers = get_auth_header(token_info['access_token'])
query = track_id
query_url = url + query
response = requests.get(query_url, headers=headers)
response.raise_for_status()
audio_analysis = response.json()
return audio_analysis
except requests.exceptions.HTTPError as http_error:
response = http_error.response
retry_after = int(response.headers.get('Retry-After', 3600)
# time.sleep(retry_after)
# return get_audio_analysis(track_id)
return response
inspecting the response with .headers returns:
{'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, 09 Oct 2023 07:21:39 GMT',
'server': 'envoy',
'Via': 'HTTP/2 edgeproxy, 1.1 google',
'Alt-Svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000',
'Transfer-Encoding': 'chunked'}As you can see, 'Retry-After' is present in the 'access-control-allow-headers' header, but not as a header itself.
Is it simply the case that not all endpoints include a 'Retry-After' header in the 429 response, or am I doing something wrong here? Any advice or answer would be appreciated.