Search code examples
pythonituneshttp-status-code-403

iTunes Search API returns 403 errors to every GET request coming from one IP


I ran a bunch of HTTP GET requests to the iTunes API endpoint below to query for a list of artist ids (200 at a time).

My script worked well for the past few months, but lately every single request coming from my server is served with a 403 status. I re-ran the same queries on my local machine and they worked fine. Then I reallocated a different IP to my server and the requests were sporadically served (most still return as 403s). Even requests for a single artist id were served 403s.

import requests
artist_ids = "<id1>,<id2>,..."
itunes_search_url = "https://itunes.apple.com/lookup?id={0}".format(artist_ids)
r = requests.get(itunes_search_url)
print r.status_code
=> 403

Does anyone know if Apple started enforcing stricter rules around the number of requests that can be made to their Search API from a single IP? I wonder if they have different rules for EC2 instances IPs than regular IPs?!


Solution

  • Closing this now, it looks like Apple recommends caching of the search API results, which is the only way I got this to work.