The Manufacturer Center (MfC) API allows apps to interact directly with the Manufacturer Center platform. To help you get started, we offer code samples in Java and .NET.
This guide will help you create your first application using the Manufacturer Center API. Before you can start coding, there are a few things you need to do.
REST Support
Our REST API supports basic CRUD operations for 2 different types of resources:
- Product for Brand Owners and Data Partners.
- And ProductCertification for Certification Bodies.
The rest of this documentation will be written mainly for Product but the process should be similar for ProductCertification.
Set up your Manufacturer Center Account
Create a Manufacturer Center Account.
Be sure to remember which email you used to create this Manufacturer Center account, as you will need that later. In the screenshots, you'll see it represented as manufacturer_user@example.com.
Make your first API request (without a line of code!)
Head over to the APIs Explorer in our developer documentation for
Accounts.Products.list
.Ensure that the logged in Google account is listed in the 'Users' setting in the Settings tab.
In the APIs Explorer, make sure that Google OAuth 2.0 is selected in the Authentication drop-down menu:
Enter
accounts/{account_id}
, replacing{account_id}
with your Manufacturer ID from your Manufacturer Center account, into the 'parent' field of the form, and click Execute.You should see a successful response. Congratulations! You've made your first Manufacturer Center API request.
If you have no products in your Manufacturer Center yet, there won't be any in the list. 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. A good next step, once you have products, is to try
Accounts.Products.get
.
Create a Google API Console Project
Requests to the Manufacturer Center API are made through your API Console project. Here we assume you will be accessing your own Manufacturer Center account, so we suggest using service accounts to simplify the authentication flow. See the Service Accounts Guide for details on how to set up a new service account to use with your Manufacturer Center account.
Your first authorized API request using Java
Now that you've set up a service account and added the service account ID to your Manufacturer Center account, you can access your account using the available Samples code. This guide uses the Java samples to demonstrate using the API.
Install Apache Maven, if you haven't already.
Download our Shopping samples from our GitHub page.
From within the
java
subdirectory, build the Java samples:$ mvn compile
Now run the
ProductsListSample
(the example for ProductCertification would beListProductCertificationsSample
) code:$ mvn exec:java -Dexec.mainClass="shopping.manufacturers.v1.samples.products.ProductsListSample"
If you haven't followed the configuration directions in the README accompanying the source files, you will get an error that no sample configuration could be found. Follow the directions in the README to create the configuration directory and to populate it with the appropriate information. The JSON file you downloaded while setting up your service account should be placed in that directory with the filename
service-account.json
. Remember to tell the code where your file is by setting the following environment variable.export GOOGLE_APPLICATION_CREDENTIALS=<Path to your JSON credentials file>
Now that you have set up the samples configuration, run the
ProductsListSample
code again.$ mvn exec:java -Dexec.mainClass="shopping.manufacturers.v1.samples.products.ProductsListSample"
At this point, the Java program 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 have not set up the service account user as an authorized user in Manufacturer Center. 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 Manufacturer Center administrators, so it would, of course, reject that request.
You can experiment with running
ProductsListSample
as many times as you want, since it is a read-only request. You can also explore the other samples that we've created for both Java and .NET.