My favorites | English | Sign in

Faster apps faster - GWT 2.0 with Speed Tracer New!

Google Base Data API (Labs)

Accessing the Google Base data API using Java

Using Java to directly access the Google Base feeds

If you prefer to interact with the Google Base feeds directly, the Google Base data API Java examples provide a tutorial to get you started. These examples do not use the Java Client Library. The code is linked from each of the documentation pages.

Although these examples are written in Java, they might also be helpful if you plan to write code in another language and want to figure out how to interact with the Google Base data API.

  • QueryExample1 performs an unauthenticated query on the public snippets feed (/feeds/snippets) and dumps the unformatted query response to the console.
  • QueryExample2 extends this by showing how to parse the result and extract data of interest from the feed.
  • QueryExample3 introduces authentication and demonstrates how to display your own items, rather than querying public snippets.
  • InsertExample demonstrates how to insert your own item into Google Base.
  • UpdateExample shows how to update a previously inserted item.

These examples assume that you know Java programming (including some basic knowledge of HTTP connections and SAX parsers) and that you are familiar with Google Base concepts. You also need to understand the following concepts before you can take full advantage of the sample applications:

Using the Java Client Library

The Google Base data API Java Client Library offers a nice object oriented abstraction for accessing the Google Base data API. There are three sample applications written in Java that show how to use the client library. You can use these as a basis for writing your own application using the GoogleBase data API Java Client Library. The code for these examples is included in the client library distribution.

  • The Recipe example demonstrates how to implement a recipe search web application. It includes code for passing an AuthSub token.
  • QueryExample is a simple Java application that demonstrates how to perform queries using the GoogleBase data API Java Client Library.
  • The CustomerTool example is a Java command-line tool that demonstrates how to make XML requests over HTTP to the GoogleBase data API and handle the XML response.

You may also find it useful to read the Java Developer's Guide, as well as the Google Base client library javadoc and the Google Data client library javadoc.

Handling errors

The sample applications do not do any error-handling in order to simplify the code, but it is good practice to include it. Refer to the Java Developer's Guide for more information.

Go to QueryExample1