Ad Sources

The AdMob API lets you view mediation ad sources programmatically. See accounts.adSources.list for additional information.

Request using Curl

  1. Load the client secrets file and generate authorization credentials.

    The first time you perform this step you'll be asked to accept an authorization prompt in your browser. Before accepting, make sure you're signed in with a Google Account that has access to the AdMob API. Your app will be authorized to access data on behalf of whichever account is currently signed in.

    For authentication and authorization, we recommend using oauth2l, a simple command-line tool for working with Google OAuth 2.0. Install oauth2l and run the command below, replacing path_to_credentials_json with a path to a credentials.json file that you download when registering your cloud application. For the first run, the command walks you through the OAuth 2.0 authorization flow. Subsequent runs refresh the token automatically.

    oauth2l header --json path_to_credentials_json --scope admob.readonly
    
  2. List ad sources.

    Get AdMob ad source information by replacing pub-XXXXXXXXXXXXXXXX with your publisher ID. See the instructions on how to find your publisher ID.

    curl --http1.0 -X GET https://admob.googleapis.com/v1beta/accounts/pub-XXXXXXXXXXXXXXXX/adSources \
     -H "$(oauth2l header --json path_to_credentials_json --scope admob.readonly)"
    

    Sample response:

    {
     "adSources": [
       {
         "name": "accounts/pub-XXXXXXXXXXXXXXXX/adSources/5450213213286189855",
         "adSourceId": "5450213213286189855",
         "title": "AdMob Network",
       }
     ]
    }