Your software on a diet!

Tuesday, September 09, 2008

Cutting API calories from your app

One of the questions we often get asked by developers is how to spend fewer API units; if you're not careful, you might end up wasting a lot unnecessarily. Thankfully, you should be able to curb your software's appetite with a few simple suggestions:

- Two ways to get there
Do you run a lot of campaigns across your client accounts? If so, you might want to schedule Campaign Performance reports instead of using the getCampaignStats method of the Campaign Service. Conversely, if you keep few campaigns, the second option is probably better.

- Bird's-eye view
Sometimes you just need to retrieve a big chunk of an account's data, with few details. If you've got a lot of campaigns, ad groups, ads, or keywords, it might be a good idea to schedule a Structure report instead. That will give you a nice list of what you're looking for in a much more scalable approach.

- Schedule once, run forever
If you often need the same report, you might want to consider scheduling a periodic report via the AdWords website. It will automatically get generated every day, every week, or every month, and
all you have to do is retrieve it with the Report Service methods.

- Look before you leap
Whenever you submit a new ad or criterion, you should always validate it first. It's true that the validation method has a cost too, but it's significantly smaller than the cost of failing the submission.

- Can I have the list?
After reading the previous item, you might be thinking that it's a good idea to only submit one item at a time. Actually, you have no benefit in doing so, because in a failed call you only get charged for the items that did in fact fail. You should always submit lists of items, since that's how our system is optimized to work -- give it a bunch of data and it will happily take care of it for you.

- Find the differences
A common mistake when updating items (ads, criteria, etc.) is to include items that haven't actually been changed. This will add to your costs, with no benefit! A simple way of making sure this doesn't happen is to keep two separate lists of items in your software: one before modification, and one after. Before submitting the changes to the service, just compare the two and remove the identical items.

- No one's looking for that
Keywords are what advertising on the search network is all about. If you have the right keywords, people will find you. If you don't, business will be slow. Consider for a moment how many poorly performing keywords you have. Every time you retrieve them, update them, or check their statistics via the API, you spend units. One very good way of saving units in the long run is to make sure that you go for the best, and skip the rest. One of the easiest ways of doing this is to use the Traffic Estimator Service before you add them, in order to get an idea of how much traffic those keywords would generate.

- Go play in the sandbox
Are you still developing your application, or trying out some new functionality? Well, no need to be spending any units. After all, playing should be free! We've got a sandbox ready for you to test your code during development which is free and open to anyone, so you can hack away without worrying about how many times you've tried to get that right.

- Check the price before you buy
Finally, you should keep in mind the cost of the various API methods, so that you don't run into any surprises after running your software. The latest rate sheet is always available at this page.

Have you come across any other useful tricks to keep API usage costs down? If so, share with others!

-Sérgio Gomes, AdWords API Team