Help to Access the Google Ads API for reporting

130 views
Skip to first unread message

Anum Hassan

unread,
Jun 28, 2021, 12:03:12 PM6/28/21
to AdWords API and Google Ads API Forum
Hi, I'm using the following link to retrieve google ads data for reporting.


Can someone please tell me if I'm going in the right direction. Also, please tell me how to fill the code here. How to fill the arguments in the parser?

if __name__ == "__main__":
    # GoogleAdsClient will read the google-ads.yaml configuration file in the
    # home directory if none is specified.
    google_ads_client = GoogleAdsClient.load_from_storage('C:/Users/Hp/Desktop/google analytics data extraction/googleads.yaml')

    parser = argparse.ArgumentParser(
        description="Retrieves a campaign stats and writes to CSV file."
    )
    # The following argument(s) should be provided to run the example.
    parser.add_argument(
        "-c",
        "-abc-def-ghi",
        type=str,
        required=True,
        help="The Google Ads customer ID of the account you would like to get "
        "the report for to write to CSV.",
    )
    parser.add_argument(
        "-o",
        "-ads.txt",
        type=str,
        required=True,
        help="Name of the local CSV file to save the report to. File will be "
        "saved in the same directory as the script.",
    )
    # Optional boolean argument for writing headers.
    parser.add_argument(
        "-w",
        "--write_headers",
        action="store_true",
        help="Writes headers to the CSV file if argument is supplied. Simply "
        "add -w if you want the headers defined in the script to be "
        "added as the first row in the CSV file.",
    )
    args = parser.parse_args()

    main(
        google_ads_client,
        args.customer_id,
        args.output_file,
        args.write_headers,
    )

Getting this error after running the file:
usage: untitled1.py [-h] -c C -o O [-w]
untitled1.py: error: the following arguments are required: -c/-abc-def-ghij, -o/-ads.txt
An exception has occurred, use %tb to see the full traceback.

Anum Hassan

unread,
Jun 28, 2021, 12:04:30 PM6/28/21
to AdWords API and Google Ads API Forum
To add to my previous message, I have the basic level access to my manager ad account.

Google Ads API Forum Advisor

unread,
Jun 29, 2021, 11:13:50 PM6/29/21
to anum.ha...@gmail.com, adwor...@googlegroups.com

Hello there,

Thank you for reaching out to us.

Since you're using the Python client library, have you tried following the steps mentioned on this guide when setting up the client library? In addition to that, we highly recommend that you reach out to the client library owners (via this link) as they're the appropriate team to provide guidance on this.

Regards,

Google Logo
Mark Kevin Albios
Google Ads API Team
 


ref:_00D1U1174p._5004Q2JWsux:ref
Reply all
Reply to author
Forward
0 new messages