API
Authentication
To use the Merchant API for Shopping with a given Merchant Center account, you must set up an API Console project. Google Cloud Console projects help you manage API access and authentication for your Merchant API solution.
Depending on the use case, there are two ways to access the Merchant API:
- OAuth 2.0 is recommended for getting access to a specific Merchant Center account through an application you developed for your users. The user will need to grant access to your account to submit data on their behalf.
- A service account is a special kind of account, typically used by an application rather than a person. A service account is identified by its email address, which is unique to the account.
Refer to how to authenticate using OAuth 2.0 or a service account.
Enable country settings
Call liasettings.update
to specify the countries where you
plan to serve local.
More information on the Country Settings Target page
Send offers data
There are two types of data: product and inventory data.
Send product and inventory data at once
Product and inventory data can be submitted at once using accounts.lfpInventories.insert
The field "GTIN" in fact will work as a product identifier for Google's catalog and a product feed will be automatically created.
This automatically created feed will show in the target Merchant Center as "Local Feed Provider" feed with the relevant offers associated with.
This method works well if all the merchant's products have a GTIN and no further features are going to be enabled (like Merchant Hosted Local Store Front basic). If you plan to enable MHLSF for your merchants, sending a dedicated product feed is the recommended setup.
The same procedure can work using accounts.lfpSales.insert
In this case the data refers to a Sale event for a particular product at a particular time.
Send product and inventory data separately
If GTINs are not widely available or you would rather take advantage of an existing product feed in the Target Merchant Center account or you want to enable MHLSF for your merchants, you need to have a specific Local Product Feed.
This can be enabled by calling accounts.productInputs.insert
first and inserting all the static values of a product. Remember to set the
Channel
attribute to "local".
Learn more about basic product data in this article and API general guidance for inserting products.
The data flow is the following:
- Call accounts.productInputs.insert first to start uploading products for your merchants
- Then Call accounts.lfpInventories.insert to submit inventory data.
Alternatively, inventory data can be sent through accounts.lfpSales.insert. A machine learning model will then predict price and quantity of the offers based on this data.
Example overview for accounts.lfpInventories.insert, accounts.lfpSales.insert accounts.lfpStores.insert
Send Business Profile data
When it is not possible to access the Merchant's Google Business Profile account to retrieve the store codes, Store data can be sent through accounts.lfpStores.insert with your own specific store codes.
Note that when calling accounts.lfpinventories.insert or accounts.lfpSales.insert the store Code will need to match the store Code provided in lfp Stores requests.
The response of accounts.lfpStores.insert will also provide a matchingState and matchingStateHint if the matching has failed.