Improve Performance

This document covers techniques you can use to improve the performance of your application. The documentation for the specific API you are using should have a similar page with more detail on some of these topics. For example, see the Performance Tips page for the Google Drive API.

About gzip

This client library requests gzip compression for all API responses and unzips the data for you. Although this requires additional CPU time to uncompress the results, the tradeoff with network costs usually makes it worthwhile.

Partial response (fields parameter)

By default, the server sends back the full representation of a resource after processing requests. For better performance, you can ask the server to send only the fields you really need and get a partial response instead.

To request a partial response, add the standard Fields parameter to any API method. The value of this parameter specifies the fields you want returned. You can use this parameter with any request that returns response data.

In the following code snippet, the GetRest method of the Discovery service is called. The value of the Fields parameter is set to description,title. As a result, the returned object will include only the description and title fields.

var service = new DiscoveryService();
var request = service.Apis.GetRest("calendar", "v3");
request.Fields = "description,title";
var result = request.Execute();

Note how commas are used to delimit the desired fields, and slashes are used to indicate fields that are contained in parent fields. There are other formatting options for the Fields parameter; for details, see the "Performance Tips" page in the documentation for the API you are using.

Partial update (patch)

If the API you are calling supports patch, you can avoid sending unnecessary data when modifying resources. For these APIs, you can call the Patch method and supply the arguments you wish to modify for the resource.

For more information about patch semantics, see the "Performance Tips" page in the documentation for the API you are using.


If you are sending many small requests you may benefit from batching, which allows those requests to be bundled into a single HTTP request.