Using the Google Shopping APIs
Danny Hermes
profiles.google.com/daniel.j.hermes
November 8, 2011
Today I hope to introduce you to the Google Shopping APIs. A basic roadmap for the next 30 minutes of your life:
- What are the Shopping APIs?
- Google Product Search and Data
- When would you use a Shopping API?
- Implementation
What are the Shopping APIs?
Product data stored in Google Merchant Center can be available on all Google Shopping Sites
10,000 Foot View of Shopping APIs
- The Content API for Shopping puts the data in the Merchant Center
- The Search API for Shopping gets the data out of the Merchant Center
Content API based on HTTP, REST & GData
With the Content API for Shopping, you can programmatically
- Upload product data for Google Product Search
- Manage sub-accounts for marketplaces
- Manage data feeds
With the Search API for Shopping
- Search for keywords for results similar to Google Product Search
- Restrict searches by key attributes such as brand and price
- Build applications on top of product data
The Search API for Shopping can be used in three cases:
- The public use case (for tinkering)
- By Google Affiliate Network publishers
- By Commerce Search customers
Google Product Search and Data
What kind of value can we add to the shopper's experience?

Define price limits

Refine results

Define her style
Imagine herself in the dress!
In order to ensure the data for product search users is of utmost quality, we try to use and combine as much data as possible. We also have a data freshness policy in place to maintain reliable results.
If the product is listed at $102 in results, the user expects to be able to buy that item for $102.
The Policy: "When a user comes to your website from Product Search, he or she expects to see the same price and availability as what is shown in Product Search results, or, what is provided in your data to us. For example, if the product is listed as being 'in stock' in results, the user expects to be able to buy that item -- it is disappointing when that item is not actually available for purchase. For these reasons, we check your website regularly to ensure information provided to us is the same as on your website - at all times. If your website and the data you provide to us do not match, your items may be suspended from Product Search results."
goo.gl/C5P8X
What does this have to do with the APIs? 
- If your item prices or quantities change often, and you'd like to be able to update your entries in the Merchant Center, the Content API is the way to go.
- If you have a massive set of items, day to day maintenance and updates can be done through the API only on the items which you wish to change.
When would you use a Shopping API?
- In such a world where shoppers are so influenced by research, you can imagine many inventive ways to use shopping data
- Can you imagine? If not, demo! If you can, still demo!
Whoa, how does that work?
import android
app = android.Android()
# Get search result
app.dialogCreateAlert('Histogram results')
app.dialogSetItems([result])
app.dialogSetPositiveButtonText('OK')
app.dialogShow()
But where does the result come from?
- Search API for Shopping feature
- Classifies results into buckets predefined by user
https://www.googleapis.com/shopping/search/v1/public/products?
facets.include=brand%3A15
&facets.enabled=true
&q=digital+camera
&key=<SEARCHKEY>
facet = simplejson.loads(response)['facets'][0]
for bucket in facet['buckets']:
labels.append(bucket['value'])
values.append(bucket['count'])
OK, What about the Content API?
The Content API for Shopping is Real Time
- Very fast for inserting new products
- Immediate for updating existing products' price or quantity information
The Content API for Shopping is Automated
- Feedback responses are in the same format as the API
- Feedback responses are on a per-item level
- Error responses are immediate, allowing for immediate retries and automation
Performance data can also be retrieved through the Content API
How do you use the APIs?
Some implementation details
Request Body containing product information formatted as XML
POST to Products Endpoint
201 Response on success
- Unique URL for each product
- Specific product operations
Response body contains new product information
Test an implementation by making real API requests through our Interactive Demo
Open Source Client Libraries:
code.google.com/apis/gdata/docs/client-libraries.html
- Put multiple product operations into a single request
- Up to 1MB in each request
- Each request can be gzipped
- Response for each batched operation
- Errors reported individually
- Save on number of requests
- Dry run mode allows testing requests without actually inserting data
- All responses, errors and warnings are returned
- Enabled by adding the dry-run URL parameter
- Also available for all state changing operations:
POST https://content.googleapis.com/content/v1/7663654/items/products/schema?dry-run
How about implementing the Shopping API?
- Much smaller specification than the Content API
- Simple GET request, immediate response
- Consists of root URI
https://www.googleapis.com/shopping/search/v1/public/products
a required developer key and several other query parameters
- Response can be either XML or JSON (simply pass the query parameter alt=atom or alt=json)
- Search by item specific attributes
- accountId
- brand
- category
- condition
- description
- gtin
- link
- price
- title
Using data to improve results:
- q - Full text search
- restrictBy - Restricting rules to restrict the result to matching products
- crowdBy - Crowding rules to diversify the products in the result
- rankBy - Ranking rule to order the products in the result
- facets - Histogram results returned for query
{
"kind": "shopping#products",
"etag": "\"g4vAy7M-xlr9t4iHvMv4hM4SrpU/UAeTlb_5PXTW_wtp3g-Gk...
"id": "tag:google.com,2010:shopping/products",
"selfLink": "https://www.googleapis.com/shopping/search/v1/p...
"nextLink": "https://www.googleapis.com/shopping/search/v1/p...
"totalItems": 1234445,
"startIndex": 1,
"itemsPerPage": 25,
"currentItemCount": 25,
"items": [
{
"kind": "shopping#product",
"id": "tag:google.com,2010:shopping/products/3622330/72699...
"selfLink": "https://www.googleapis.com/shopping/search/v1...
"product": {
"googleId": "7269998773346629677",
"author": {
"name": "Apple Store",
Resources
- Active online communities on Google Groups
- Forums supported by myself and other engineers. Answers are searchable, adding to a knowledge base of developer questions
- Docs and Samples on our site
- Issue Tracker:code.google.com/p/shopping-api-issues/issues/list
Thank you!
Q & A