Batching calls to Google APIs (Javascript)
One of the benefits of having a standardised API layer across all the (recent) Google APIs is that a bunch of features come for free. One of these handy items is batching, which is generally pretty easy to do. For example, an awful lot of Google+ Sign-In implementations retrieve both the signed-in user's profile information and the collection of friends the user shared with the app when the user connects. This generally necessitates two calls, two connections, and two lots of overhead, but can be easily combined into a single request. If you take a look at the Google+ Javascript QuickStart you'll see there is a profile function and a people function, each making a call to gapi.client.plus.people.something , and then request.execute . We can replace that with a single function that combines both, and looks a little like this: All we've done here is created each request, and a new RPC batch with gapi.client.newRpcBatch() . It's called RPC batch as we're actua