Chapter 4 the search api for shopping, Request format – Google Commerce Search Deployment Guide User Manual

Page 17

Advertising
background image

Chapter 4 The Search API for Shopping

The Search API for Shopping (Shopping API) is what allows you to search the products fed
into Merchant Center. The Shopping API is typically implemented in server-side code (Java,
php, .Net, and so on) which takes a user’s search query, makes an API call to Google, and gets
the search results back--presenting them to the user.

This chapter covers some of the common use cases for the Shopping API and discusses overall
implementation architecture, but it does not give specific coding examples. The Shopping API
provides a rich set of features, and there are a number of ways that a search application can be
implemented. For example code, see the GCS Admin Toolkit at

http://code.google.com/p/gcs-admin-toolkit/

Best Practice: Use a GET request for your search form--this allows easy tracking of query
parameters via Google Analytics. It also allows users to easily bookmark search results pages.

Request format

The Shopping API has a wealth of features that enable you to build robust search interfaces. It
is a RESTful API, so the results of an API call are controlled by the parameters in the URL of
the request. Some of the things these parameters control are:

Number of results returned, pagination options

Sorting order of results

Which attributes, facets or fields are returned

Refinement & Filtering options

Format of results (XML, JSON)


This chapter covers some of these parameters, but for detailed technical documentation for the
Shopping API, go here:

http://code.google.com/apis/shopping/search/

URL format
There are a few parameters that are required for all Shopping API requests. Here’s simple
request URL:

https://www.googleapis.com/shopping/search/v1/
cx:016458501645884057912:dq_ixbwhuk8/products?
key=<DEVKEY>&country=us&alt=atom&q=shirt

The following table lists the required fields in this URL.

cx:016458501645884057912:dq_ixbwhuk8

(This one is for the Google Store’s products)

Your Unique Search Engine Identifier
This ties the query to your GCS control panel
and Merchant Center Feed.

key=<DEVKEY>

This must contain your API key
(from https://code.google.com/apis/console/)

country=us

The API currently returns offers only from

17

Advertising