Google Ads API (AdWord API) Get Started

Google Ads API Setup Guide – Get Started with Google Ads API

Enable Google Ads API and generate credentials using Google console – Step-by-step guide

Hi, Hope you are doing well. Thank you so much for stopping by. It’s another day to learn something fruitful. To give you an idea of what we will be learning here. The guide will help you in creating Google console projects, we will be enabling Google Ads API, next we will be generating tokens (access token, client id, etc) for OAuth Authentication through which we will be using Google Ads API to get Google Ads and Campaigns performance data.

What is Google Ads?

Google Ads is an online advertising platform developed by Google, where advertisers bid to display brief advertisements, service offerings, product listings, or videos to web users. For more details visit Link.

What is Google Ads API?

The API provided by Google enables interaction with the Google Ads platform directly. It makes it easy and efficient to manage large or complex Google Ads accounts and campaigns.

A developer can easily build software with this API. With help of API, one can automate account management, custom reporting, ad management, and much more functionality. The API can do everything the Google Ads UI does but programmatically.

Google Ads API (AdWord API) Get Started

1. Create a Project in Google Console and Enable API

To access a Google Ads account through API calls, you need to turn on Google Ads API first. In order to do that go to Google Console, create an app or select an app (If you already have a project/application created in google console).

Are you finding it difficult and confusing to create a project or App in google console? Don’t worry we got you covered – here’s a Detail Guide to Creating Google Console Projects.

1.1. Select Google Console Project

As you can see from the image below, I have selected “Google Ads” (that’s my application or project name).

1.2. Search and Enable API

To enable the API, confirm you are in the “Dashboard” view and look out for the “ENABLE APIS and SERVICES” button and click on it. Hope you find it soon!

Look for Google Ads API (an easy way is to search for it). Click on it and enable the API for your project by clicking on the “ENABLE” button.

I recommend creating a new app under google console, specific to your application to avoid confusion. Another suggestion is to name this application “Google Ads”.

2. Generate project credentials and OAuth-related tokens

After you have enabled the API for your project it’s time to generate credentials for your project so that you can use them from the application you are building. To do so refer to the 3rd step of the Guide to Creating Google Console Project.

Suggestion: name this credential after the type of API or Application. In this case for example it will be google_ads_api_cred. Don’t forget to keep the note of the client id and client secret you will get at the end of the 3rd step. That means you should now have client_id= XXXXXXXX and Client_secret = XXXXXXXX.

Next, we will see how to generate tokens. For this again we will refer to the  Guide to create Google Console Project step 4. This is the most important process to generate a token for OAuth verification. (NOTE: There are 2 ways mentioned in step 4, you can choose whichever suits you best and meets the requirement).

3. Get a Developer Token

A developer token from Google allows your app to connect to Google Ads. To get your developer token sign in to your Manager Account. (note: you should be signed in as a Google Ads Manager Account).

Navigate to TOOLS & SETTINGS > SETUP > API Centre. You should see a developer token or you will see an API access form (you need to fill up the form and complete the entire process to get the developer token).

The API Centre option will appear only for Google Ads Manager Accounts.

NOTE: Developer token must be approved before using it with production Google Ads accounts. If you are stuck here and not able to figure out any solution, I recommend you should get some help from the detailed Sign-Up Guide.

If you want I can help you out with a python code to generate an access token and the entire process automated. Get in touch with me. This all can be done in 1 hour for you.

4. Python code to authenticate and make the first API call

4.1 Create a JSON file

    "client_id":"Replace with Client Id",
    "client_secret":"Replace with Client Secret",
    "access_token":"Replace with Access Token",
    "refresh_token":"Replace with Refresh Token",
    "developer_token" :"Replace with Developer Token",

4.2 Python code

#python3 ./ 
import sys
import json
import time
from datetime import datetime
import pandas as pd
from import GoogleAdsClient

def google_ads_authentication(token):
        google_ads_client = GoogleAdsClient.load_from_dict(token)
        print("\nFunction (google_ads_authentication) - authentication process finished successfully ")

        return google_ads_client

        print("\n*** Function (google_ads_authentication) Failed *** ",sys.exc_info())

def get_google_ads_customer(client):

    customer_service = client.get_service("CustomerService")
    customer_resource_names = (customer_service.list_accessible_customers().resource_names)

    customer_id_list = []

    googleads_service = client.get_service("GoogleAdsService")

    for customer_resource_name in customer_resource_names:
        customer_id = googleads_service.parse_customer_path(customer_resource_name)["customer_id"]
    #print("\n customer_id_list : ",customer_id_list)
    query = """
        SELECT customer_client.client_customer, customer_client.level, customer_client.manager,
            customer_client.descriptive_name, customer_client.currency_code, customer_client.time_zone,,
        FROM customer_client
        WHERE customer_client.level <= 1 and customer_client.test_account = 'false'

    #and customer.test_account != TRUE PARAMETERS include_drafts=true

    for c in customer_id_list:
            response =, query=query)
            acc = None
            for d in response:
                customer_client = d.customer_client
                #print("\ncustomer detail : ",customer_client)
                if customer_client.level == 0:
                    if acc is None:
                        acc = customer_client
                        tmp = {"id","name":acc.descriptive_name, "time_zone":acc.time_zone}
                # else:
                #     print("\n level not 0 ",customer_client)
    account_dt = pd.DataFrame(final_list)
    return account_dt

if __name__ == '__main__':
        timestamp = datetime.strftime(,'%Y-%m-%d : %H:%M')
        print("Get Google Ads account details process Started at ",
        start = time.process_time()

        #Read the Credentials from the JSON file.
        cred_file = "./google_ads_cred.json"
        cred_data = open(cred_file, 'r')
        google_ads_cred = json.load(cred_data)

        client = google_ads_authentication(google_ads_cred)
        accounts_details_df =  get_google_ads_customer(client)
        print("\n Account Details :\n",accounts_details_df)

        print("\nGet Google Ads account details process ends at ",
        print("Processing Time : ",(time.process_time()-start))
        print("\n *** Get Google Ads account processing Failed :", sys.exc_info())

Congratulations! You have successfully set up and got all the credentials needed to authenticate your application on behalf of the user so that you can use the above API. Hope I have made the entire process of Getting Started with Google Ads API simple enough. Here’s a guide to help you with Python Code using Google Ads API to retrieve ads and campaign performance data.

Hope I was able to solve the problem. If you like this article and think it was easy to understand do share it with your friends and connection. Thank you! See you soon.

For any suggestions or doubts ~ Get In Touch

Checkout out my other API Integration and Coding Solution Guide