Get Started

This guide will help you create your first application using the Content API. Before you can start coding, there are a few things you need to do.

Set up your Merchant Center Account

  1. Create a Merchant Center Account.
  2. Verify and claim your website URL.
  3. Configure your Tax & Shipping settings.
  4. Be sure to remember which email you used to create this merchant center account, as you will need that later. In the screenshots, you'll see it represented as “”.

Make your first API request (without a line of code!)

  1. Head over to the APIs Explorer in our developer documentation for a products list.
  2. Ensure that the logged in Google account is in the 'Users' list in the settings of your Merchant Center account. This is illustrated below:

  3. In the APIs Explorer, toggle the button to authorize requests using OAuth 2.0:

  4. Click Accept to authorize a Google-created API Console Project to temporarily access your Merchant Center account on your behalf to make an API request. Note that this screen should come from, and you should be signed in to your Merchant Center email address.

  5. Enter your Merchant ID from your Merchant Center account into the 'merchantId' field of the form, and click Execute.

  6. You should see a successful response. Congratulations! You've made your first Shopping API request.
  7. If you have no products in your Merchant Center yet, there won't be any in the list. But never fear, we'll add some soon. At this point, you can hop to other requests and take a look at what they do. Since this is a RESTful API, all requests work similarly. Good next steps include Products.insert, Inventory.set, and Accountstatuses.get.

Create a Google API Console Project

Requests to the Content API for Shopping are made through your API Console project. You will 'authorize' your API Console project to make requests on your behalf using OAuth2. The username (email address) associated with the Merchant Center account to be accessed must be the same email that accepts the OAuth2 authorization. Let's look at it in more detail:

  1. Go to the Google API Console.
  2. From the project drop-down, select an existing project, or create a new one (you can name it anything you like).
  3. Enable the Content API for Shopping service:
    1. In the list of Google APIs, search for the Content API for Shopping service.
    2. Select Content API for Shopping from the results list.
    3. Select Enable API.
  4. Next, you need to set up the screen Google will show the user when you request their authorization to access their products. In the left-side menu under "API Manager", select Credentials, then select the OAuth consent screen tab.
    1. Choose an Email Address, enter your website/app's name as the Product Name, and select Save.
    Once saved, you end up on the Credentials tab.
  5. Next, set up your OAuth2 client ID.
    1. In the Credentials tab, select the Create credentials drop-down, then select OAuth client ID.
    2. Under Application type, choose Other and provide a name. Click Create.

    The Oauth client ID and secret appear. Leave this page open for now, as you will need the generated credentials in the next section.

Your first authorized API request using Python

Now we will need to authorize your API Console project to access your Merchant Center account through the Content API for Shopping. This is because the API Console project is acting on your behalf to access your Merchant Center account. Your authorization will allow it to act "as you" in this process. This guide will use Python to demonstrate the API. Other languages are available at our Samples and Libraries page.

  1. Use pip to install the Python client library and the OAuth2 client. More detailed instructions are available here.

    $ pip install --upgrade oauth2client
    $ pip install --upgrade google-api-python-client 
  2. Download our Python samples from our GitHub page.

  3. Run the file, similar to what we did in the API Sandbox earlier. Enter your merchant ID as a command line argument:

    $ python <merchant_id>
  4. You will get an error explaining that you must populate the client_secrets.json file. Go ahead and open that up, and refer to the API Manager Credentials page from your API Console project to fill in the Client ID and the Client Secret. Do not share the Client Secret with anyone, as they will be able to access your API Console project with that information!

  5. Now that you have modified your client_secrets.json file, run again (with your merchant ID as an argument as before).

    $ python <merchant_id>
  6. Your terminal will redirect you to your browser to visit a site that starts with Ensure that the link opens in a browser that is signed in with the same account that you used to create the Merchant Center account, or one that is in the 'Users' list in Merchant Center settings. This step is analogous to the step in the APIs Explorer when you flipped the toggle to authorize the API Console project to make requests on your behalf. This time, you are doing it with your own project, and you are driving the request with your own code.

  7. Accept the authorization and you should receive a success message.

  8. At this point, the Python script should finish executing, and print out either a list of products that it found, or a message that there were no products in your account. If you get an error such as "User cannot access account 1234567890", it's most likely because you were logged into the wrong account when you authorized the app. From the API's standpoint, the API Console project sent a request on behalf of a user who was not on the list of authorized Merchant Center administrators, so it would, of course, reject that request.

  9. You can experiment with running as many times as you want, since it is a read-only request. You can also explore the many other samples that we've created.

At this point, you've got a well suited environment for developing with the Content API for Shopping. You can now move on to learning more about Making Requests and Best Practices.

Send feedback about...

Content API for Shopping