Thursday, May 31, 2012

Google API JavaScript Client Reaches Beta

We are pleased to announce the Beta release of the Google API JavaScript Client. This release represents an improvement in stability and features bug fixes and some new functionality. Continue reading for a breakdown of the changes in this release.

New Features

RPC Batching

It is now possible to make batched RPC requests, allowing multiple API calls to be made on one server round-trip. Making a batch request is simple, simply create RPC requests as normal, add them to a batch, and execute the batch. Read more on the project's batch wiki page.

Create RPC Requests Directly

There is a convenient new way to directly create RPC requests, rather than first registering the RPC method. The new method is:

var rpcRequest =
  gapi.client.rpcRequest(method, version, rpcParams);

For example, to search G+ profiles:

var searchRequest =
      'query': 'mark'

The formal method definition can be found in the project's Reference Docs.

Response Callback Improvements

Changes were made to the response callbacks to provide more detailed information to aid in building and debugging applications. All callbacks now receive two response parameters. The first is unchanged, it contains the parsed JSON response to the request. The second parameter is the raw response as a string. This allows manipulation of non-JSON responses. For REST requests, this also provides access to the full response body, headers, status, and status text. The Reference Docs have been updated to reflect the changes in response callback parameters.

Fixed Issues

  • Fixed a WebKit issue in which navigating away from a page using the JS Client and then returning via the back button would cause requests to start failing.
  • Fixed an issue where 401 (unauthorized) errors were being trapped by the JS Client and the request callback would not fire. Now the callback will be called with the correct error response.
  • Cleaned up documentation, fixing errors and typos.

Please try out the new functionality and report any issues you find in the issue tracker, or send a message to the JS Client discussion group.