Google APIs Get Faster Thanks to Smart Optimizations

“Doing more with less” is one of those mantras that developers can quite often ignore thanks to ever increasing bandwidth, memory and CPU speeds. Google has once again bucked this trend, this time by announcing that they intend to implement changes that can be used to optimize most of their API’s that are based on the Google Data Protocol:

Today, we’re proud to take our first big step in making APIs faster by introducing two experimental features in the Google Data Protocol, partial response and partial update. Together, partial response and partial update can drastically reduce the network, memory, and CPU resources needed to work with Google APIs.

The changes mean that developers can now specify which fields should be returned by the server, meaning only the data that is required is actually transmitted:

With the addition of partial response you can now use the fields query parameter to request only relevant information -- in this case, event titles and times. Constructing such a request using the fields query parameter is simple:

GET HTTP://,gd:when)

By including the entry argument and specifying title and gd:when, this request ensures that the partial response contains only the title and time for each event, along with a small amount of wrapping metadata.

In addition, the partial update feature allows developers to modify the returned data:

Simply edit the data you received in the partial response and use the HTTP PATCH verb to send the modified data back to the server. The server then intelligently interprets your PATCH, updating only the fields you chose to send. Throughout this entire read-modify-write cycle, the unneeded data remains server-side and untouched.

For such a simple concept, the benefits can be quite significant. The blog post mentions a scenario where a partial response managed to reduced the amount of data that was transferred by 95%. You can easily try this demo for yourself. If you are logged into your Google Account, compare the response size of this partial calendar feed to this full calendar feed.

Right now four Google APIs have implemented the new partial response and update functionality: YouTube, Calendar, Picasa Web Albums and SideWiki data. However Google is planning to add it across the range of APIs that are built on the Google Data Protocol.

Be sure to read the next Best Practices article: 7 Ways to Make Your API More Successful