This page explain how you can create a Merchant Center account and upload a sample product using Merchant API.
Before you begin
Enable Merchant API in your Google Cloud project.
Create an account
To use the Merchant API, you must have a Merchant Center account. To create a Merchant Center account, see Get started with Merchant Center.
Get your account ID
You can obtain the account ID by using the
accounts.list
method.
You can use the Google APIs Explorer to run Merchant API requests. APIs Explorer uses Google OAuth 2.0 for authentication. Before running the requests, make sure that the Google OAuth 2.0 checkbox is ticked.
To authenticate using OAuth 2.0, you need to sign in to your Google Account, and then sign in to APIs Explorer. You also need to allow APIs Explorer to manage your product listings and accounts.
The following request shows how you can retrieve your account ID:
GET https://merchantapi.googleapis.com/accounts/v1beta/accounts
After the request successfully runs, you see the following response:
{
"accounts": [
{
"name": "{ACCOUNT_NAME}",
"accountId": "{ACCOUNT_ID}",
"accountName": "{ACCOUNT_DISPLAY_NAME}",
"timeZone": {
"id": "America/Los_Angeles"
},
"languageCode": "en-US"
}
]
}
Copy the {ACCOUNT_ID}
because you will need it to run other requests.
Create a primary products data source
To insert a product, you need a primary products data source. The following request shows how to create a data source you can use to insert a product to your account:
POST https://merchantapi.googleapis.com/datasources/v1beta/accounts/{ACCOUNT_ID}/dataSources HTTP/1.1
{
"primaryProductDataSource": {
"channel": "ONLINE_PRODUCTS",
"contentLanguage": "en",
"countries": [
"US"
],
"feedLabel": "US"
},
"name": "primary-data-source",
"displayName": "Primary Products Data Source"
}
Replace the {ACCOUNT_ID} with the ID of the Merchant Center account you created.
After this request is successfully run, you see the following response:
{
"name": "accounts/{ACCOUNT_ID}/dataSources/{DATASOURCE_ID}",
"dataSourceId": "{DATASOURCE_ID}",
"displayName": "Primary Products Data Source",
"primaryProductDataSource": {
"channel": "ONLINE_PRODUCTS",
"feedLabel": "US",
"contentLanguage": "en",
"countries": [
"US"
],
"defaultRule": {
"takeFromDataSources": [
{
"self": true
}
]
}
},
"input": "API"
}
Copy the value of the name
field because you will need it for inserting a
product.
It takes a few minutes for the created data source to be available for inserting products.
You can view this data source in the Merchant Center UI. For more information, see How to find the Data sources tab.
Insert a product
To insert a sample product to your account, run the following request:
POST https://merchantapi.googleapis.com/products/v1beta/accounts/{ACCOUNT_ID}/productInputs:insert?dataSource={DATASOURCE_NAME} HTTP/1.1
{
"channel": "ONLINE",
"contentLanguage": "en",
"feedLabel": "US",
"name": "Red T-shirt",
"attributes": {
"gender": "Male",
"brand": "New brand"
},
"offerId": "tshirt-123"
}
Replace {DATASOURCE_NAME} with the value you copied earlier.
After this request is successfully run, you see the following response:
{
"name": "accounts/{ACCOUNT_ID}/productInputs/online~en~US~tshirt-123",
"product": "accounts/{ACCOUNT_ID}/products/online~en~US~tshirt-123",
"channel": "ONLINE",
"offerId": "tshirt-123",
"contentLanguage": "en",
"feedLabel": "US",
"attributes": {
"brand": "New brand",
"gender": "Male"
}
}
The product ID for the newly created product is online~en~US~tshirt-123
. You
can use the
accounts.products.get
method to retrieve details about this product. You can also use the Merchant
Center UI to view this
product.