Interactive Google Base data API Demo

Google Base is a place where you can submit all kinds of content for Google to host and to make searchable online. You can describe any item you post with descriptive attributes, which can be labels or specific information about the good or service. The more attributes you associate with your items, the more different ways users can find them.

With the new Google Base data API, you can create specialized applications that handle such actions programmatically. Your application can upload new data, update or delete existing items, and execute specialized queries to find matches for complex attribute criteria.

The Google Base data API is compliant with the Google data API framework, which combines common XML-based syndication formats (Atom and RSS) with a feed-publishing system based on the Atom publishing protocol. The Google data API Developer's Guide has more information about the protocol. You can perform queries, inserts, updates, and deletes with the Google Base data API, all of which, except for queries, require authentication at this time.

This demo page provides you with a simple mechanism for using the API and learning how it works. Each Google Base data API operation has an equivalent HTTP method, so you can try out the HTTP GET, POST, PUT, and DELETE methods as you invoke the operations below. The page uses Javascript to execute, which may also be useful for you as you learn to build your own applications.

Google Base uses two feeds for data:

A good way to start learning how to use the Google Base data API is to do a couple of sample inserts and queries. This document takes you through the minimal set of actions to insert a new data item and execute a simple query with HTTP.

The interactive demo explained in this page is written in JavaScript, which handles the HTTP requests for you.

The demo includes these sections:

Authenticating users

For authentication to work, each user must have a valid Google account.

The Google data API supports two ways of authenticating users: for installed applications (Programmatic Login) and for web applications (AuthSub). This interactive demo uses the AuthSub authentication system whereby users authorize the web application to act on their behalf and gets redirected back to the application with a token that the application includes in the header of subsequent HTTP requests.

In order to use this interactive demo, you need to first get a new single-use AuthSub token. Once you have that, you can upgrade to a multi-use session token.

Get new single-use AuthSub token.
Current single-use token:

Trying out the API

Note that you must be authenticated before you can use this demo.

Select an operation:

Query (HTTP GET)

Query URI: /base/feeds/  

Request

Response

Insert (HTTP POST)


Request

Response

Update (HTTP PUT)

Item ID:

Copy the item ID from an Insert response. The item ID is the 19-digit number at the end of the URL in the Location response header.


Request

Response

Delete (HTTP DELETE)

Copy the item ID from an Insert response. The item ID is the 19-digit number at the end of the URL in the Location response header.

Item ID:  

Request

Response

Batch


Request

Response


Querying for items

A Google Base query is a specially encoded URL that contains your search parameters and uses an HTTP GET method to communicate with the server.

Queries in the Google Base data API are REST-style URIs that can perform a simple full text search or invoke a more complex structured query that limits the search to specific attributes or item types . The results are returned as an Atom feed, although you can specify RSS-formatted results. The Google Base data API Developer's Guide describes how to form these parameterized URIs and the Recommended Attributes list shows you which attributes you can query on. You also can query a metadata feed to get more information about popular attributes.

There are two feeds for querying items:

Here is a list of sample queries for the snippets feed. The parameter bq is used to specify a structured Google Base query. You can copy and paste them directly into the query text box below in order to send the query to the API server.

Items containing the terms digital and camera:
snippets?bq=digital+camera
Cameras of brand Canon: digital camera [brand: canon]
snippets?bq=digital+camera+%5Bbrand%3Acanon%5D
At most five results for the query:
snippets?bq=digital+camera&max-results=5
Requests results in RSS format for the query:
snippets?bq=digital+camera&alt=rss
Items of type Products containing the terms digital and camera in the area of San Francisco: digital camera [item type: products] [location: @"San Francisco, CA" + 50mi]
snippets/-/products?bq=digital+camera+%5blocation:@%22San+Francisco,CA%22%2b50mi%5d

The response is an Atom (or RSS) feed that contains a list of all data items that match the query string. Each item has a unique URL (in the <id> tag), so you can retrieve an individual item later by using its specific URL.

The release package provides a couple simple command-line tools that demonstrate how to interact with the API in Java as well as a simple web application implementing a frontend for finding and submitting recipes shows how to use Google Base data API feeds in web applications. These are described in the Google Base data API Developer's Guide.

Querying for metadata

Each data item in Google Base is an instance of an item type. The item types promoted by Google come with a set of approved attributes. Such metadata can be queried with the API by using the /base/feeds/itemtypes feed. Here are some sample queries. You can copy and paste them directly into the query text box below in order to send the query to the API server. Note that the query string you paste in has been URL encoded.

All suggested item types for locale en_US with their corresponding attributes.
itemtypes/en_US
All suggested attributes for item type Recipes:
itemtypes/en_US/recipes

You can find out which attributes and which attribute values are more commonly used in Google Base item by querying the /base/feeds/attributes feed. Here are some sample queries:

Frequent attributes for items containing the terms digital and camera.
attributes?bq=digital+camera
Frequent attributes and attribute values for cameras of brand Canon.
attributes?bq=digital+camera+%5Bbrand%3Acanon%5D&max-values=5

Inserting, updating, and deleting single items

You can insert new items and update or delete your own items through the /base/feeds/items feed. The invoke section provides some sample data for a new item entry. If you want to update or delete, you need to use the correct item ID.

Verifying your data

You can verify the results of your operations by going to the Google Base Frontend and looking at the list of your items.

Any data provided to Google Base can take up to 24 hours to become searchable. You can view your own items by using the items feed.

A few points to note about the code:

<id>http://www.google.com/base/feeds/items/1263232256914517833 </id>

This URL uniquely identifies the data item:

 

Updated on