We will sunset v2 of the Content API on March 29th, 2021. To avoid disruptions with your integration, please migrate to v2.1 as soon as possible. For more information, see Migrating to v2.1.

Setting Up a Client Library

We recommend using the Content API via the Google API client libraries. The client libraries are available for many popular programming languages and simplify common API tasks, such as user authentication, sending requests, and parsing responses. This guide uses the Content API sample code to demonstrate how to set up the Google API client library for Python to use with the Content API. For more information on setting up client libraries for other languages, see the README.md for the language within the googleads/googleads-shopping-samples repo on GitHub.

To set up the Google API client library for Python, complete the following steps:

  1. Create a directory for the client library's configuration and authentication files. Within your home directory, create the following directories:

    ~/shopping-samples/content/

  2. To download your service account credentials, complete the following steps:

    1. In Merchant Center, in the Settings menu, select Content API.
    2. Click Authentication.
    3. Click [+] CREATE API KEY.
    4. If prompted, read and accept the terms of service agreements.

    The new key downloads automatically.

  3. Rename the downloaded credentials file to service-account.json.

  4. Move the service-account.json file to your home directory/shopping-samples/content/.

  5. In your home directory/shopping-samples/content/, create an empty merchant-info.json file.

  6. In merchant-info.json, add the following text:

    {
    "merchantId": your Merchant Center merchant ID,
    "accountSampleUser": "the email address associated with your Merchant Center account"
    }
    
  7. Clone (or download and unzip) the googleads/googleads-shopping-samples GitHub repo to any location on your computer; it does not have to be in your home directory or in ~/shopping-samples/content/.

  8. If you downloaded and unzipped the repo, instead of cloning it, rename the unzipped directory to googleads-shopping-samples.

  9. To install the required sample dependencies, in a terminal window, navigate to googleads-shopping-samples/python/ and run:

    pip install -r requirements.txt
    

You now have the Google API client library for Python configured and ready to use with the Content API. In the next section, you’ll create and send a request to insert a new product.