Search code examples
app-storeitunes

iTunes search JSON API returning 403 forbidden on server


For the six weeks or so, we have been able to execute queries against the iTunes search JSON API without issue. Starting this week, we started to see 403 errors after a certain number of requests (about 1K - 2K). We're assuming this is a rate-limiting issue, perhaps a new policy they implemented. Is there another explanation we're overlooking?


Solution

  • As you are looking to get price and ratings my guess is that you are doing a lookup, not a search, with the iTunes Search API.

    If that assumption is true then you can "batch" lookup requests by listing multiple ADAM IDs in a query by separating them with a comma.

    eg. To get results for both of these apps in the US --

    https://itunes.apple.com/us/app/9-innings-2013-pro-baseball/id530061728?mt=8

    https://itunes.apple.com/us/app/homerun-battle-2-free/id491221570?mt=8

    -- you'd do this: https://itunes.apple.com/us/lookup?id=491221570,530061728

    I believe the limit is 50 ids per query.

    If there are approximately 900K apps currently live in the App Store, some quick math shows that before batching, if you evenly spread out your requests you'd be doing ~625 queries / minute. (900K / 24 hours / 60 minutes == 625)

    However, if you batch them in groups of 50 then you are looking at about 13 queries / minute (900K / 50 per request / 24 hours / 60 minutes == 12.5). This should be well within the allowed limit.

    ...@Crashalot - if you are doing app recommendations, then we should talk.