Set up a client library

We recommend using the Google API client libraries to set up the Content API for Shopping. This guide uses the Python Content API client libraries as an example, but they're available for many popular programming languages and simplify common API tasks like authentication, sending requests, and parsing responses. For help 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.