Google Ad Manager Node.js API
A modern wrapper around Google's Ad Manager API.
Features
- Promise based - use Promise or async/await
- Non opinionated about auth mechanisms - obtain a token however you like
- Typed (TypeScript)
Install
npm i --save google-ad-manager-api
Usage
Step #1
Obtain an access token in whatever way you like, for example using Google Auth Library's JSON Web Tokens mechanism:
; ; ;client.scopes = ;await client.authorize;
Step #2:
Create a DFP client:
;;
Step #3
Use the client to create a service, and pass the auth token from step #1:
;lineItemService.setTokenclient.credentials.access_token;
Or even shorter (pass the token directly to getService
:
;
Step #4
Invoke service methods:
; console.logres.results.id;
Notes
- The Ad Manager API returns an
rval
field for each method invocation. To make things easier for us, this package will return the content of that field. For example, invocation ofLineItemService.getLineItemsByStatement
will return aLineItemPage
object directly. - Google auth tokens have expiration dates and they need to be updated or refreshed in some way. Because authentication management is outside the scope of this package, make sure to always pass the new tokens to the services instances using
service.setToken
.