My favorites | English | Sign in

Try Google Chrome's developer tools New!

Google Base Data API (Labs)

Reference Guide

This document provides detailed reference documentation for the Google Base Data API.

Contents

  1. Audience
  2. Base feed types
    1. Data feeds
      1. Snippets feed
      2. Items feed
      3. Media feeds
    2. Metadata feeds
      1. Itemtypes feed
      2. Attributes feed
      3. Locales feed
  3. Attribute types
  4. Feed parameter reference
    1. Standard query parameters
    2. Additional query parameters
    3. Insert, update, delete and batch parameters
  5. Base elements reference
    1. Data feed elements
    2. Media feed elements
    3. Metadata feed elements
  6. Base Feeds Schema Reference

Audience

This document is intended for programmers who want to write client applications that can interact with Google Base.

It's a reference document; it assumes that you understand the concepts presented in the Developer's Guide and the general ideas behind the Google Data APIs protocol. It also assumes that you have read the Getting Started guide to learn how manage items in Google Base, as well as the Attributes and Queries chapter to learn how to run queries.

Base feed types

Base provides a variety of representations of Base data. There are two main types of feeds: data feeds and metadata feeds. Data feeds are used to manage data, such as product or real estate listings. The read-only metadata feeds are used to obtain information about how the data feeds should be constructed, including locale-specific information or which attributes they should use.

Data feeds

There are two main data feeds: the snippets feed and the items feed.

Snippets feed

The URL for the snippets feed is:

http://www.google.com/base/feeds/snippets

The snippets feed is read-only.

The snippets feed contains all Google Base data and is available to anyone to query against without a need for authentication. The snippets feed provides access to all content in Google Base, but may return items with a shortened description. Snippets feed entries do not include private attributes.

Items feed

The URL for the items feed is:

http://www.google.com/base/feeds/items

The items feed is read-write.

The items feed contains a customer-specific subset of Google Base data. The items feed requires authentication.

You can use the customer items feed to insert, update, delete, or search for your own data. In response to queries, this feed returns a list of your own data items that match the query provided as a parameter in the URL of the feed. The difference between this feed and the snippets feed is that the items feed contains only the customer's own data. Thus any query against this feed will only retrieve your own entries, which means you may get different results than you would by running the same query on the public snippets feed.

In Google Base, each item type has a set of recommended attributes predefined for it. To see this list, you can request an item types feed or look at the Recommended Attributes document. You do not have to restrict yourself to this list, but if you do, you can get more statistics about your data.

The items feed has an associated media feed.

Media feeds

The URL for each media feed is:

http://www.google.com/base/feeds/items/item_id/media/ 

Each media feed is read-write.

You can use the media feeds to manage binary attachments to your Google Base items.

The media feeds differ from the other Google Base feeds in that there is one media feed defined per Google Base item (rather than one global feed, as with the other feeds.)  Each item's media feed manages binary attachments for that item.

You can use an item's media feed to:

  • add and delete binary attachments for that item, and
  • query for information about an item's attachments.

Each item may contain up to 10 attached binary files. 

Attachments uploaded via the media feed are processed immediately.  For each passed attachment, Google Base creates a set of thumbnails of the attachment, and stores the thumbnails on the Google Base server.

Metadata feeds

There are three metadata feeds: the itemtypes feed, the attributes, and the locales feed.

Itemtypes feed

The URL for the itemtypes feed is:

http://www.google.com/base/feeds/itemtypes/<locale>

The itemtypes feed is read-only.

It contains a complete description of Google Base structures and allows you to query for different types of metadata. It provides a list of attributes associated with each of the Google Base item types. See Attributes and Queries for some sample queries that show how to use this feed.

Attributes feed

The URL for the attributes feed is:

http://www.google.com/base/feeds/attributes/

The attributes feed is read-only.

It provides statistics about how an item type has been used and lists what values have been used frequently for its attributes. This feed can also show you how others have defined the item in existing entries. This information can be very helpful as you define new items to upload. See the language-specific developer's guides linked on the left for code samples that show how to access this feed through the Google Base client libraries.

Locales feed

The URL for the locales feed is:

http://www.google.com/base/feeds/locales/<locale>

The locales feed is read-only.

It defines the permitted locales for Google Base. The locale value identifies the language, currency, and date formats used in a feed.

locale limits the feed to return information for a single location. Currently, the following locales are defined:

Country Code
United States en_US
Great Britain en_GB
Germany de_DE

Attribute types

Google Base supports attributes of various types. The following attribute types are supported in Google Base:

Type (Atom Feed) Type (Queries) Description Examples
text text Any string or text value Blue
int int Integer 1000
float float Floating-point numbers 3.5
number number Either an int or a float 1000
or
3.5
intUnit int * Integer with a unit consisting of at least one term 10 km
floatUnit float * Floating-point number with a unit consisting of at least one term 1.5 km
numberUnit number * A number (either int or float) with a unit consisting of at least one term 10 km
or
1.5 km
boolean bool Value may be either y or n y
date date A date in the form YYYY-MM-DD 2005-12-12 (see note below on date formats)
dateTime date Date and time in the format YYYY-MM-DDThh:mm:ss 2005-12-12T12:00:00

Dates are specified in the international format defined by ISO 8601. The standard defines several alternatives, but only the following format is supported: yyyy-mm-ddThh:mm:ssZ (the Z is optional). Only times in UTC are supported.
dateTimeRange daterange Range of dateTime values. In queries date ranges have the syntax
YYYY-MM-DDThh:mm:ss..YYYY-MM-DDThh:mm:ss
In the Atom entries, a date range simply consists of two consecutive date time values denoting the start and end date/time.
2005-12-12..2005-12-19 (see previous note on date formats)
location location Location a full address such as 1600 Amphitheatre Parkway, Mountain View, CA, 94043, USA, or a partial address such as Mountain View, CA, 94043
Note that you must enter a valid address which can be geocoded by Google.
In the query language, location strings are prefixed with an @ character; i.e. the above address would be written as: @"1600 Amphitheatre Parkway, Mountain View, CA.
url url URL http://www.google.com
reference reference A reference to another item in Google Base In the query language, reference strings are prefixed with an # character; i.e. the query would be written as: #123456789. The result would be: http://www.google.com/base/feeds/snippets/123456789

Feed parameter reference

This section describes the query and path parameters that can be used on the Google Base feeds.

Standard query parameters

Base supports the following standard Data API query parameters on all feeds.

The list of parameters is separated from the URL by the ? character. The & character is used to separate each subsequent parameter in the list.

Standard query parameters

The following URL parameters are supported for Google Base queries on all feeds.

Parameter Meaning Default value Notes
alt

requests results in an alternative format atom

If you don't specify an alt parameter, the service returns an Atom feed. The other alternatives are:

alt=rss returns a feed in RSS 2.0 format.

alt=json returns a feed in JSON format.

alt=json-in-script returns a response that wraps JSON in a script tag.

callback causes the specified JavaScript function name to be executed when the data from Google Base is loaded. None This parameter is only used when alt is set to json-in-script.
key API key None Every request you send must be authenticated using an API key. Refer to the Getting Started chapter for more information.
max-results maximum number of entries to return per page 25 The maximum value is 250.
start-index where to start retrieving the search results. 1

This is a 1-based index of the first result to be retrieved.

For the snippets feed, start-index must be greater than or equal to 1 and less than 1000. The sum of start-index + max-results cannot be greater than 1000.

For the items feed, start-index must be greater than or equal to 1 and less than 10,000. The sum of start-index + max-results cannot be greater than 10,000.

Note that this isn't a general cursoring mechanism.

If you first send a query with ?start-index=1&max-results=10 and then send another query with ?start-index=11&max-results=10, the service cannot guarantee that the last 10 results are equivalent to ?start-index=1&max-results=20, because insertions and deletions could have taken place in between.

Additional query parameters

In addition, Base supports the following Data API query parameters on the noted feeds.

Parameter Meaning Default value Notes Supporting feeds
adjust transforms query results so the returned items include the adjusted values, rather than the original text. You may specify true or false. false

Query adjustments are always enabled, and adjusted values are included transparently by default. In some cases you might want to streamline the adjusted values by preventing the gm:adjusted_name and gm:adjusted_value tags from appearing in query results. To do this, add the adjust=true parameter to the feed URL.

For example, the following entry:

<entry><g:item_type>
<gm:adjusted_value>
recipes
</gm:adjusted_value>
recipe
</g:item_type>
<g:cook_time>
<gm:adjusted_name>
cooking time
</gm:adjusted_name>
10 minutes
</g:cook_time>
<g:main_ingredient>
<gm:adjusted_value>
chicken
</gm:adjusted_value>
poultry
</g:main_ingredient>
</entry>


will be transformed as follows if you specify adjust=true:

<entry>
<g:item type>
recipes
</g:item type>
<g:cooking time>
10 minutes
</g:cooking time>
<g:main_ingredient>
chicken
</g:main_ingredient>
</entry>

Be aware that the items returned by a feed on which adjust has been set to true may not appear as the original author intended. Adjustments are added automatically and consequently are subject to error. Specify adjust=true only if you're willing to accept incorrect or incomplete information in exchange for not having to parse <gm:adjusted_name> and <gm:adjusted_value>.

Items, Snippets
bq is a query string that conforms to the Query Language Specification. None

See the Attributes and Queries document for details on query syntax.

If you want to get data about all of the items, you can leave off the ?bq=[query-string] component, as follows:

http://www.google.com/base/feeds/snippets or http://www.google.com/base/feeds/items

Items, Snippets, Attributes
content controls the content returned for each entry in a query request. attributes

content can have the following values for all noted feeds:

  • none : specifies that only elements from the atom: namespace should be returned.
  • all: specifies that elements from the atom:, g:, and gm: namespaces should be returned. all also returns thumbnails.
  • attributes : specifies that elements from the atom: and g: namespaces should be returned.
  • meta : specifies that the tags gm:stats and gm:adjusted should be returned.
  • adjustments: specifies that gm:adjusted_name and gm:adjusted_value should be included in query results.
  • thumbnails: specifies that links to generated thumbnails should be included in query results.
  • geocodes: specifies that if an item contains <g:location> data, the geocoded <g:latitude> and <g:longitude> data should also be returned.

In addition, content can have the following value for the Items feed:

  • stats : specifies that the gm:stats elements should be returned.

To include more than one value, separate them with a comma (except for none and all, which are shortcuts). For example, to get attributes and statistics but no adjustments, you would specify attributes,stats.

Items, Snippets
crowdby is used to define crowding criteria for queries. 1

The syntax for the value of crowdby is a comma-separated list of crowding and maxvalue pairs:

crowdby=crowding:maxvalue,crowding:maxvalue, crowding:maxvalue

crowding: is the crowding criteria. You can use any of the following criteria:

  • attribute filters results based on the specified attribute.
  • url filters results based on the URL.
  • customerid filters results based on the customer ID.
  • content filters results based on the content of the title and description attributes in the item.
  • [crowding expression] uses an expression for crowding.
maxvalue is an integer number greater than or equal to 1.
Items, Snippets
/itemtype

The itemtype parameter may be used to search for entries that correspond to a specific category, based on the item type.

None

The syntax is http://www.google.com/base/feeds/snippets/-/itemtype .

You can query on multiple categories by listing multiple category parameters, separated by slashes.

To query on a union of categories (OR queries), use a pipe character ( | ), URL-encoded as %7C. For example: http://www.google.com/base/feeds/snippets/-/products%7Cservices returns entries that match either the products category or the services category.

Since every item belongs to exactly one item type, queries on an intersection of categories (AND queries) will not yield any results.

To exclude entries that match a given category, use the form /-categoryname/

When you use a category query on the attributes or itemtypes feed, the response to your query includes a link that points to the snippets feed where more data can be found about this item type. This allows you to write code that automatically takes you to the next level of detail. The link uses a category search, with " /-/" prefix to indicate that the query is to get all items with the item type that follows. For example, your query result might contain the following link:

<link 
rel="related"
type="application/atom+xml"
href="http://www.google.com/base/feeds/snippets/-/jobs"
title="Items in jobs"/>

For additional syntax information, refer to the Google Data API /category parameter documentation.

Items, Snippets, Attributes

max-values The number of distinct values returned in each entry. Most frequent N values along with their counts are returned.

5

  Attributes
orderby is used to define the ranking order for sorted queries. relevancy

orderby can have the following values:

  • relevancy: specifies that query results should be sorted by relevancy. This is the default behavior.
  • modification_time: specifies that query results should be sorted by last modification time. The most recently modified item has the highest rank.
  • name(type): name refers to an attribute name and type refers to a numerical attribute type (i.e. int or float, possibly with a unit.) The items are ordered by the value of the specified attribute.
  • [<ranking criteria>]: This is a custom ranking criteria specified in the ranking query language. The Ranking Language reference explains what you can do with this language and defines the language syntax.
Items, Snippets
q is the standard Data API parameter that denotes a full-text query string. None
  • When creating a query, list search terms separated by spaces, in the form q=term1 term2 term3. (As with all of the query parameter values, the spaces must be URL encoded.) The service returns all entries that match all of the search terms (like using AND between terms). Like Google's web search, a Google Data API service searches on complete words (and related words with the same stem), not substrings.
  • To search for an exact phrase, enclose the phrase in quotation marks: q="exact phrase".
  • To exclude entries that match a given term, use the form q=-term.
  • The search is case-insensitive.
  • Example: to search for all entries that contain the exact phrase "Elizabeth Bennet" and the word "Darcy" but don't contain the word "Austen", use the following query: ?q="Elizabeth Bennet" Darcy -Austen

Items, Snippets, Attributes

refine refines the query results. You may specify true or false. false

If refine is set to true, the Google Base data API will rewrite "item type" restricts ITR of the form [item type: term1 ... termN] , [item type: "term1 ... termN"] and [item type == "term1 ... termN"] to ITR [attrib1] ... [attribM] where attribI are names of attributes that we believe are essential for the item type specified by ITR. In other words, this refinement adds additional restrictions to an item type attribute query which guarantees to match items that have a certain number of core attributes.

The purpose of this mechanism is to restrict search results to items that reuse a certain number of attributes we consider to be essential for a given item type. This may improve the quality of certain search results, especially for queries that have many matching items.

On the other hand, setting refine to true might lead to items getting dropped that actually match the specified query. This is, in particular, bad for the customer-specific items feed, because it can give the impression that some attributes are missing, when in fact they simply do not meet the undocumented quality assumptions that this parameter introduces.

Because of this, refine is set to false by default. It should be enabled to improve quality of broad queries.

For example, if refine is set to true,

[item type: recipes] [label:asian]

gets rewritten to:

[item type: recipes] [cooking time] [main ingredient] [label:asian]

On the other hand, [item type: products | services] does not get refined with additional attribute restrictions, because this item type query does not match the specified format.

Items, Snippets
sortorder specifies whether sorted query results are returned in increasing or decreasing order. descending

sortorder can have the following values:

  • ascending: specifies that items should be returned in increasing rank.
  • descending: specifies that items should be returned in decreasing rank.

If sortorder is specified but orderby is not, the results will be sorted by relevancy in the specified order.

Items, Snippets

Insert, update, delete and batch parameters

In addition to the standard Data API query parameters, the noted read/write feeds support the following insert, update, delete, and batch parameters.

Parameter Meaning Default value Notes Supporting feeds
dry-run is used to test a feed operation before it is actually executed. Once you are sure that you want to submit the data, remove the dry-run flag to execute the operation. false dry-run can be set to true or false. Items, Media

Base elements reference

The Google Base Data API uses three types of elements: data feed elements, metadata feed elements, and media feed elements. For information about the standard Google Data API elements, see the Atom specification and the Kinds document.

Data feed elements

Data feed elements are used in the items and snippets feeds to describe data.

Each entry of the snippets or items feed corresponds to one data item in Google Base. Each sub-element of the entry in the g: namespace corresponds to an attribute of the corresponding data item. Sub-elements have the form:

<g:attrib_name type="attrib_type">
   value
</g:attrib_name>

These are defined as follows:

Element Description
attrib_name specifies the attribute name.
attrib_type specifies the content type of the attribute. See Google Base attribute types for available types.
value specifies the value of the attribute.

Media feed elements

The media feed uses the following elements. These elements belong to the media namespace.

Element Description
media:content groups thumbnails of consistent sizes.
media:thumbnail points to a single thumbnail.

Metadata feed elements

Metadata feed elements are used in the itemtypes, attributes, and locales feeds to represent metadata.

Google Base uses the following elements in the itemtypes feed:

Element Description Supporting feeds
gm:attributes specifies a list of attributes. Attributes, Itemtypes
gm:attribute identifies a single attribute by name and type. Attributes, Itemtypes
gm:item_type is the name of the item type. Itemtypes
gm:value is the value for each of the most frequently used values for this attribute. Attributes

Note that these elements use the gm: namespace. This namespace contains the metadata attributes that are used in the item types and attributes feeds. No other feeds use them and they are read-only, so users do not need to use this gm: namespace to input the attributes. The only impact on users is that you will see an extra line in the response, giving the location of the namespace, xmlns:gm ='http://base.google.com/ns-metadata/1.0.

 

Base Feeds Schema Reference

  1. Attributes Feed
  2. Item Types Feed
  3. Items Feed
  4. Locales Feed
  5. Media Feed
  6. Snippets Feed