The AdSense service allows you to use the AdSense Management API in Apps Script. This API gives AdSense customers the ability to get information about the structure of their account and run reports on how it is performing.
Reference
For detailed information on this service, see the reference documentation for the AdSense Management API. Like all advanced services in Apps Script, the AdSense service uses the same objects, methods, and parameters as the public API.
To report issues and find other support, see the AdSense Management support guide.
Sample code
The sample code below uses version 1.4 of the API.
List ad clients
This sample lists all of the ad clients within the user's default account. Notice the use of page tokens to access the full list of results.
List ad units
Listing ad units is very similar to listing ad clients but requires an ad client ID, which can be obtained from the previous sample.
Generate a report
This sample generates a report over your AdSense account and outputs the results to a spreadsheet.