Using AWCLI (AdWords Command Line Interface)

Tuesday, October 04, 2011

Earlier this year we released a demo that allows you to run AdWords API queries from the command line. Today, a new version is available and I’d like to point out some of its features.

Accessing production environment

We’ve made a change to reduce a risk of accidentally running the demo tool against a production environment. Since version 1.2.0, an explicit ‘--prod’ flag is required in order to query billable services. Check out ‘awcli --help’ for all available command-line options.

Automatic batch mode

AWCLI can now run in interactive or batch mode and detects the required mode automatically. In interactive mode, you will get a prompt to type your commands:

In batch mode, any extra input is suppressed and the application exits after a command completes. This makes it easier to use the tool in shell scripts:
bash $ echo ls | ./
    #1 Campaign Name [69266990]
bash $

You can also specify a command and its parameters as extra arguments to the tool itself:
bash $ ./ --prod ls 69266990
    #1 AdGroup name [2390064350]
bash $

Browsing Ad Parameters

A new CriterionLocation was added which allows you to browse Criteria. This enables you to list and view AdParams associated with your criteria:
bash $ ./ [options] ls <campaign_id>/<adgroup_id>/<criterion_id>
    #1 $100 [1]
    #2 50 [2]
bash $
...and even edit them: 'edit #1' will spawn your configured editor. The changes will be automatically applied when you save and exit.

Querying stats

You can combine AWCLI output with other command-line tools to retrieve parts of the information you need. For example, you can use Unix filters to obtain ad group stats:
bash $ ./ --prod cat <campaign_id>/<adgroup_id> | grep -E "clicks|impressions"
        clicks = 12,
        impressions = 160,
bash $

Getting AWCLI

AWCLI is available from the Google Code page and is part of the AdWords Java API client libraries project. You can find installation and running instructions as well as usage examples on the wiki page. Please join us to discuss the tool and report any issues on the project page or forum.

Danial Klimkin, AdWords API Team.