google-api-client overview (2.9.0)

com.google.api.client.googleapis

Google APIs.

com.google.api.client.googleapis.apache.v2

Google APIs support based on the Apache HTTP Client.

com.google.api.client.googleapis.apache.v5

Google APIs support based on the Apache HTTP Client v5.

com.google.api.client.googleapis.auth.oauth2

Google's additions to OAuth 2.0 authorization as specified in Using OAuth 2.0 to Access Google APIs.

Before using this library, you must register your application at the APIs Console. The result of this registration process is a set of values that are known to both Google and your application, such as the "Client ID", "Client Secret", and "Redirect URIs".

These are the typical steps of the web server flow based on an authorization code, as specified in Using OAuth 2.0 for Web Server Applications:

These are the typical steps of the browser-based client flow specified in Using OAuth 2.0 for Client-side Applications:

com.google.api.client.googleapis.batch

Batch for Google API's.

com.google.api.client.googleapis.batch.json

JSON batch for Google API's.

com.google.api.client.googleapis.compute

com.google.api.client.util.Beta
Support for Google Compute Engine.

com.google.api.client.googleapis.extensions.android.accounts

com.google.api.client.util.Beta
Utilities for Account Manager for Google accounts on Android Eclair (SDK 2.1) and later.

com.google.api.client.googleapis.extensions.android.gms.auth

com.google.api.client.util.Beta
Utilities based on Google Play services.

com.google.api.client.googleapis.extensions.appengine.auth.oauth2

Google App Engine utilities for OAuth 2.0 for Google APIs.

com.google.api.client.googleapis.extensions.appengine.notifications

com.google.api.client.util.Beta
Support for subscribing to topics and receiving notifications on servlet-based platforms.

com.google.api.client.googleapis.extensions.appengine.testing.auth.oauth2

com.google.api.client.util.Beta
Test utilities for the com.google.api.client.googleapis.extensions.appengine.auth.oauth2 package.

com.google.api.client.googleapis.extensions.servlet.notifications

com.google.api.client.util.Beta
Support for subscribing to topics and receiving notifications on servlet-based platforms.

com.google.api.client.googleapis.extensions.servlet.notifications.jakarta

com.google.api.client.util.Beta
Support for subscribing to topics and receiving notifications on servlet-based platforms using jakarta.servlet namespace.

com.google.api.client.googleapis.javanet

Google API's support based on the java.net package.

com.google.api.client.googleapis.json

Google's JSON support (see detailed package specification).

Package Specification

User-defined Partial JSON data models allow you to defined Plain Old Java Objects (POJO's) to define how the library should parse/serialize JSON. Each field that should be included must have an @com.google.api.client.util.Key annotation. The field can be of any visibility (private, package private, protected, or public) and must not be static. By default, the field name is used as the JSON key. To override this behavior, simply specify the JSON key use the optional value parameter of the annotation, for example @Key("name"). Any unrecognized keys from the JSON are normally simply ignored and not stored. If the ability to store unknown keys is important, use com.google.api.client.json.GenericJson.

Let's take a look at a typical partial JSON-C video feed from the YouTube Data API (as specified in YouTube Developer's Guide: JSON-C / JavaScript)


 "data":{
  "updated":"2010-01-07T19:58:42.949Z",
                  "totalItems":800,
                  "startIndex":1,
                  "itemsPerPage":1,
                  "items":[
                          {"id":"hYB0mn5zh2c",
                                  "updated":"2010-01-07T13:26:50.000Z",
                                  "title":"Google Developers Day US - Maps API Introduction",
                                  "description":"Google Maps API Introduction ...",
                                  "tags":[
                                          "GDD07","GDD07US","Maps"],
                              "player":{
                              "default":"http://www.youtube.com/watch?v=hYB0mn5zh2c" },
                              ...
                          }]}
 

Here's one possible way to design the Java data classes for this (each class in its own Java file):


 import com.google.api.client.util.*;
 import java.util.List;

 public class VideoFeed {
   @Key public int itemsPerPage;
   @Key public int startIndex;
   @Key public int totalItems;
   @Key public DateTime updated;
   @Key public List<Video> items;
 }

 public class Video {
   @Key public