Select your language

This Python 3 code snippet demonstrates the usage of the Google Ads API (formerly known as AdWords API), to generate and retrieve a report. The code can be modified to retrieve all kinds of reports (in the example, a report of type CLICK_PERFORMANCE_REPORT is requested as CSV).



  • App Setup in the Google Developer Console with Google Ads API enabled
  • Google Ads API key (to get from your MCC under TOOLS & SETTINGS > SETUP > API Center)
  • Generate a refresh token using the script from the Google Ads API examples
  • Copy the googleAds.yaml example file from the Google Ads API Examples to your script directory and insert your client-id, client-secret, API key and refresh token
  • Install the Google Ads Python Library (pip install googleads)


Code Snippet

# -*- coding: UTF-8 -*-

from googleads import adwords
from googleads import errors
import time
import datetime
import os
import sys

if __name__ == '__main__':

  ## initialize google adwords client object
  adwords_client = adwords.AdWordsClient.LoadFromStorage("googleAds.yaml")

  ## set your customer-ID

  report_downloader = adwords_client.GetReportDownloader(version='v201809')

  ## get CLICK_PERFORMANCE report for yesterday as an example
  report_date =
  report_date_string = report_date.strftime("%Y%m%d")

  ## build the report query
  report_query = (adwords.ReportQueryBuilder()
      .Select('GclId','CampaignName', 'AdGroupName', 'CriteriaParameters')

  ## download the report as CSV into string
  csv_report = report_downloader.DownloadReportWithAwql(
      report_query, 'CSV', skip_report_header=True,
      skip_column_header=True, skip_report_summary=True,

   ## do whatever you want with the generated report