This page shows how to programmatically create and update your data sources that let you insert products. Automated data sources make it easier to send your product data to Google. Automated data sources make sure that the most up-to-date information about relevant products from your website reach Google.
Content API for Shopping only lets you create primary data sources. With Merchant Data sources API, you can create the following types of data sources:
- Primary product data sources
- Supplemental product data sources
- Local inventory data sources
- Regional inventory data sources
- Promotion data sources
- Product review data sources
- Merchant review data sources
Content API for Shopping only lets you manage data sources with file input. Merchant API lets you manage data sources with both file and API inputs.
Using Merchant Data sources API, you can do the following:
- Create a new primary data source with a specific
feedLabel
andcontentLanguage
. - Create a data source that doesn't have
feedLabel
andcontentLanguage
fields set. Using this type of data source you can target multiple countries for your products, as you can insert products with different combinations offeedLabel
andcontentLanguage
into a single data source. - Create a supplemental data source to link to an existing primary data source.
- Set up a schedule for a file data source.
- Enroll your account for automatic management of data sources.
- Manage API data sources.
- Manage the default rule of data sources using primary product data sources.
- Use other types of data sources like promotions.
You cannot use Merchant API to insert products in a data source that contains both local and online products. For more information about data sources channels, see Channels.
Prerequisites
- Your account must have been migrated to single locale feeds.
To verify that the account is already migrated to data target split, use the data source list or get methods. In case you aren't eligible, you will receive the following exception message and you should contact support.
This account is in the data sources migration process and can't be used with this API yet. Contact support for more info on when this account will be able to use the data sources endpoint.
Create a new data source
Primary data sources are the main data sources for your Merchant Center inventory. You can only add or remove products using a primary data source. If every product you add to your primary data source meets Merchant Center's data and eligibility requirements, you won't need to create any more data sources.
To create a new primary data source with a specific feedLabel
and
contentLanguage
, set the feedLabel
and contentLanguage
fields in the
type-specific configuration. For more information about these fields,
see PrimaryProductDataSource
.
For more information about creating a data source, see the accounts.dataSources.create method.
To view your newly created data source, use the accounts.dataSources.get or accounts.dataSources.list method.
Create a new primary data source that helps target multiple countries
To create a new primary feed that helps you target multiple countries, configure
your data source using
PrimaryProductDataSource
and don't set the feedLabel
and contentLanguage
fields.
Using Content API for Shopping, there is only one API data source created for
you. Using Merchant Data sources API, you can have multiple API data sources,
some of which can be without the feedLabel
and contentLanguage
fields set.
Only data sources with API input can be without the feedLabel
and
contentLanguage
fields set. This type of data sources isn't supported for file
inputs.
Create a supplemental data source and link it to the primary data source
Supplemental data sources are used only to update product data that already exists in one or more primary data sources. You can have multiple supplementary data sources, and each one can supplement data in any number of primary data sources.
You can use supplemental data sources to make partial updates to product data by
adding the unique identifier of the data source as a query parameter when making
calls to the
accounts.productInputs.insert
and
accounts.productInputs.delete
methods. You can only use supplemental data sources to update existing products.
To create a supplemental data source, configure your data source using
SupplementalProductDataSource
and then link it by updating the defaultRule
field on your primary data source.
Supplemental file data sources must have the feedLabel
and contentLanguage
fields set. Supplemental API data sources must always have the feedLabel
and
contentLanguage
fields unset.
Set up a schedule for your file data source
To set up a schedule for your file feed, configure your data source to be a file
data source by using the FileInput
field and then set up
fetchsettings
using the FileInput.FetchSettings
field.
Delete a data source
To delete an existing data source from your account, use the
accounts.dataSources.delete
method.
Fetch data source
To fetch a file configured in the data source, use the
accounts.dataSources.fetch
method. This method perform the data fetch immediately on a data source from
your account. This method only works on data sources with a file input set.
Get data source
To retrieve the data source configuration for your account, use the
accounts.dataSources.get
method.
List data source
To list the configurations for data sources for your account, use the
accounts.dataSources.list
method.
Patch data source
To update the configuration of an existing data source, use the
accounts.dataSources.patch
method.
Link data sources
Primary product data sources let you manage the default rule of data sources. The default rule is the rule that applies to all attributes in your data source. The default rule can be set while creating the data source or by updating an existing data source through the default rule field.
The following sample configuration ensures that all attributes are first taken
from the data source with the unique identifier 1001
. Then the missing
attributes are added from the primary data source. Eventually, the remaining
attributes will be taken from the supplemental data source with the unique
identifier 1002
if not already provided in any other data source. If the same
attribute is provided in multiple data sources, the value higher in the list is
selected.
defaultRule {
takeFromDataSources: [
'1001', // Supplemental product data source
'self', // Self reference to the primary data source
'1002' // Supplemental product data source
]
}
Auto-management of feeds
To enroll your account for automatic management of data sources, you must do the following:
- Check whether your account is eligible for enrollment by calling the
accounts.autofeedSettings.getAutofeedSettings
method. - Make sure that you account isn't a marketplace account.
After your account is eligible for enrollment, you can use the
accounts.autofeedSettings.updateAutofeedSettings
method to enable automatic management of data sources. Enabling automatic
management of data sources lets Google automatically add your products from your
online store and ensure they are always up to date on Google's platforms.
Retrieve file upload status
To get the status of a data source with either file, fetch or spreadsheet, you
can call the GET
method of the
accounts.dataSources.fileUploads
service. To obtain the result of the last retrieval of the data source computed
asynchronously when the data source processing is finished, use the name
identifier latest
.
GET https://merchantapi.googleapis.com/accounts/v1beta/{accountId}/datasources/{datasourceId}/fileUploads/latest
The file upload status might contain a detailed view of your products, including any potential issues.
Note that the file upload status might not exist if the file was never uploaded. The file upload status might be in the processing state if requested soon after the file is uploaded.