Queue API Calls

Work around eBay’s API call limit.

Developers working under the Individual license, explained at the beginning of this chapter, have a strict limit as to the number of eBay API calls they are allowed to make each day.

Provided that your application uses the API efficiently [Hack #125] , this shouldn’t pose a problem. And as the theory goes, anyone needing more than 50 API calls per day is probably running a business on eBay and can justify the cost of one of the higher developer tiers.

Consider the following scenario. As a seller, you might have 55 separate auctions ending on a single day. If you use the script in “Automatically Keep Track of Items You’ve Sold” [Hack #112] , you can retrieve sufficient data for all your recently closed auctions with only a single GetSellerList call. But if you use the script in “Spellcheck All Your Listings” [Hack #116] , you’ll need a minimum of 56 calls: one to retrieve the list of auctions, and 55 more to retrieve the individual auction descriptions. Run this single script just once, and you’ll exceed your API quota for the day.

If you feel that exceeding your quota is a possibility, you can take some extra steps to ensure both that your software understands this limit, and that if your software reaches the limit, it can queue additional API calls and complete its work the next day.

The first step is to begin recording your API call usage. Probably the best way to do this is by adding a counter to the call_api subroutine in the

Get eBay Hacks, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.