v1.4 of the AdSense Management API is now deprecated. This version will stop returning data on October 12, 2021. Please migrate to v2 as soon as possible.

Method: accounts.adclients.getAdcode

Gets the AdSense code for a given ad client. This returns what was previously known as the 'auto ad code'.

This is only supported for ad clients with a productCode of AFC.

For more information, see About the AdSense code.

HTTP request

GET https://adsense.googleapis.com/v2/{name=accounts/*/adclients/*}/adcode

The URL uses gRPC Transcoding syntax.

Path parameters

Parameters
name

string

Required. Name of the ad client for which to get the adcode. Format: accounts/{account}/adclients/{adclient}

Request body

The request body must be empty.

Response body

If successful, the response body contains data with the following structure:

Representation of the AdSense code for a given ad client.

For more information, see About the AdSense code.

JSON representation
{
  "adCode": string,
  "ampHead": string,
  "ampBody": string
}
Fields
adCode

string

Output only. The AdSense code snippet to add to the head of an HTML page.

ampHead

string

Output only. The AdSense code snippet to add to the head of an AMP page.

ampBody

string

Output only. The AdSense code snippet to add to the body of an AMP page.

Authorization Scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/adsense
  • https://www.googleapis.com/auth/adsense.readonly