Are you getting started with the AdWords API but short on time to read the documentation? Do you need a reference implementation of a particular API operation? Check out our client libraries code examples which have undergone extensive renovations in the last libraries release!

The code examples are one of the best resources to learn the API and understand version changes. It is also helpful to have a working code to troubleshoot issues you may have with your own implementation. You can find the list of the client libraries and the resources for each library on the AdWords API site.

There were a number of changes introduced which we hope will make the examples code base more useful and easy to follow:
  • The code examples are now oriented around typical use cases rather than the API-specific operations. To get Criteria report look for the getCriteriaReport example, to create text ads - for the createTextAds example.
  • The number of input parameters was reduced which means you can run more examples as-is now, without adding specific object IDs.
  • For each example the code is wrapped into a function which can be called with parameters. This makes it easier to find out what parameters are required and improves examples testability.
  • Some of our Best Practices are now also demonstrated in the examples and described in the comments.
We’ve also changed the example files layout. We’ve noticed developers find it easier to navigate defined sections:
  • BasicOperations: start here if you are new to the AdWords API. This directory contains examples of basic operations such as creation, updating and deletion of most commonly used objects. The examples demonstrate the principles used in the rest of the API: selectors, predicates, paging, grouping of operations.
  • Targeting, CampaignManagement: these sections contain more advanced examples on the AdWords API such as geo targeting, location extensions, experiments and ad parameters.
  • ErrorHandling: examples in the ErrorHandling directory demonstrate how to handle different kind of errors occurring during the API calls. The errors covered here are API-specific (e.g. not network errors) and not transient so they could not be solved by retrying the exact same request.
  • Reporting: this section includes examples on how to retrieve a report with the client libraries. You can find the list of reports and their fields available on our codesite page.
  • AccountManagement: examples in the AccountManagement section will be helpful if you manage more than one account via the API. Here you can find code which retrieves accounts’ hierarchy or finds units spent on particular account.
  • Optimization: If you are looking for keyword or placement ideas or traffic estimations, you can find the examples in this section.
  • Remarketing: conversion tracker and audience operations are shown in examples in the Remarketing section.
  • Misc: this section contains examples that don’t fit into any other category and also some library-specific code samples. Check out our OAuth authorization code example here.
Browse updated examples code in: DotNet, Python, Ruby, Perl, PHP. We are working to update examples for Java and JavaScript as well.

As always, please feel free to ask any questions regarding the AdWords API on our forum or during scheduled office hours.