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
Content API for Shopping only allowed managing 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 wildcard data source. A wildcard data source doesn't have
feedLabel
andcontentLanguage
fields set. Wildcard data sources let you insert products with different combinations offeedLabel
andcontentLanguage
into a 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.
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
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 example, PrimaryProductDataSource
.
To view your newly created data source, create a GET
or a LIST
request.
Create a new wildcard primary data source
To create a new wildcard primary feed, 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 wildcard.
Only data sources with API input can be wildcard data sources. Wildcard data sources aren't supported for file inputs.
Create a supplemental data source and link it to the primary data source
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 cannot be wildcard data sources. Supplemental API data sources must always be wildcard data sources.
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.Get
method. - Make sure that you account isn't a marketplace account.
After your account is eligible for enrollment, you can use the
Accounts.AutofeedSettings.Update
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 FileUpload
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.