Google Code offered in: English - Español - 日本語 - 한국어 - Português - Pусский - 中文(简体) - 中文(繁體)
This document provides detailed reference documentation for the Google Base Data API.
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 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.
There are two main data feeds: the snippets feed and the items feed.
Snippets feedThe 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.
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.
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:
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.
There are three metadata feeds: the itemtypes feed, the attributes, and the locales 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.
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.
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 |
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 |
This section describes the query and path parameters that can be used on the Google Base feeds.
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.
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
|
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, For the items feed, Note that this isn't a general cursoring mechanism. If you first send a query with |
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 For example, the following entry:
Be aware that the items returned by a feed on which |
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
|
Items, Snippets, Attributes |
content |
controls the content returned for each entry in a query request. | attributes |
In addition,
To include more than one value, separate them with a comma (except for |
Items, Snippets |
crowdby |
is used to define crowding criteria for queries. | 1 |
The syntax for the value of
maxvalue is an integer number greater than or equal to 1. |
Items, Snippets |
/itemtype |
The |
None |
The syntax is You can query on multiple categories by listing multiple category parameters, separated by slashes. To query on a union of categories ( Since every item
belongs to exactly one item type, queries on an intersection of categories ( To exclude entries that match a given category, use the form 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 " <link For additional syntax information, refer to the Google Data API /category parameter documentation. |
|
max-values |
The number of distinct values returned in each entry. Most frequent N values along with their counts are returned. |
|
Attributes | |
orderby |
is used to define the ranking order for sorted queries. | relevancy |
|
Items, Snippets |
q |
is the standard Data API parameter that denotes a full-text query string. | None |
|
|
refine |
refines the query results. You may specify true or false. |
false |
If 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 Because of this, For example, if
gets rewritten to:
On the other hand, |
Items, Snippets |
sortorder |
specifies whether sorted query results are returned in increasing or decreasing order. | descending |
If |
Items, Snippets |
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 flag to execute the operation. |
false |
dry-run can be set to true or false. |
Items, Media |
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 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. |
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 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.