A Node.js driver for Google Adwords Reporting API (v201603)
- License (ISC)
To install google-adwords-reports, run
npm install google-adwords-reports
then include in your file the following:
var ga = ;
This function is used to set client access information, specifically the
clientSecret and the
developerToken fields. This is also used prior to each call to set the
clientCustomerID and the
Any call to Google Adwords automatically refreshes the accessToken for the call. This may be overridden by including both the
accessToken and the
tokenExpires in the user setting along with the
clientCustomerID and the
ga;// Sets Client options for usage in your app.
ga;// Sets user options if you wish to refresh the token on every call.
ga;// Sets user options if you do not wish to refresh every call. Will refresh if expiration is hit.
Once the appropriate access information has been set with
.use(), you may use
.awql() to make calls to your reports. You may do this in a number of ways: chaining, options object, or AWQL string. All options return a Bluebird promise, with
.catch for successful and failing use cases, respectively.
.awql() chaining, simply chain additional keywords onto your query like this:
Alternatively, you can pass arrays into
You may also add a
.where() and a
.and() into the chain after
.from(), allowing for drilling of information:
You can chain additional `.and() functions after the first:
Alternatively, you can pass an array of
.and() statements into the first:
You can also access the reports by passing an object into
.awql() as such:
var options =select: 'Date' 'Clicks'from: 'ACCOUNT_PERFORMANCE_REPORT'during: '20120101' '20150125'includeZeroImpressions: false // defaults to truega
As with the promises above, you may pass both strings or arrays to
Finally, you can pass your own AWQL string into
.awql. Make sure there are no spaces in your
where statements, as this string will replace all spaces (besides
+ for proper API sending.
var awqlStatement = 'SELECT Date, Clicks FROM ACCOUNT_PERFORMANCE_REPORT DURING 20120101, 20150125'ga;
All request return information in the following format:
report:'Title of the Report'timeframe: 'Timeframe of the report'total: 'Overall total of the report'fieldLength: 7 // Integer: The number of fields (columns) that are being returneddata: // contains objects of individual report rows returnedauth: // This is the updated auth from the request. You may pipe this back in using ga.use()accessToken:'accessTokenString'tokenExpires: 1424716834341 // Integer: Unix Timestamp of expiration time
.awql() calls return two promise chains,
.catch() as outlined in the Bluebird documentation. You may use
.catch() to catch any issues that may have arisen in the call.
ga// selecting invalid fields
To contribute code to this module, please follow this workflow:
- fork the repo
- make sure to install dev dependencies using
npm install --dev
- Make the changes you desire
- Ensure all changes have a new test in the
test/folder, and run:
This will check do the following:
- Check your code against feross/standard style and notify of any issues.
- Run all mocha tests listed in
- Run all code through istanbul's code coverage runner. You can check the coverage afterwards the coverage report page:
- After making changes in your fork, open a pull request.
Please note that if your code updates do not pass JS Standard style, mocha tests and code coverage, your PR may be rejected and you'll need to fix any issues listed in it.
v1.1.6 - 2018-03-27
- Replace deprecated google adwords api v201708 with v201802
v1.1.0 - 2015-03-13
v1.1.1 - 2015-03-13
.jshintrcto make codeclimate happy with JS Standard Style
v1.1.0 - 2015-03-13
- Converted to feross/standard style
- Updated tests and scripts in package.json
- Updated contributing docs
v1.0.0 - 2015-02-23
Copyright (c) 2015, Trent Oswald (therebelrobot)
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.