
fields=kind,items(title,characteristics/length) Request for a partial response: The following request for this same resource uses the fields parameter to significantly reduce the amount of data returned. Simple request: This HTTP GET request omits the fields parameter and returns the full resource.įull resource response: The full resource data includes the following fields, along with many others that have been omitted for brevity. The following example shows the use of the fields parameter with a generic (fictional) "Demo" API. To reduce the amount of data you send when modifying resources, use a patch request. Note that the fields parameter only affects the response data it does not affect the data that you need to send, if any. You can use this parameter with any request that returns response data. To request a partial response, use the fields request parameter to specify the fields you want returned. For better performance, you can ask the server to send only the fields you really need and get a partial response instead. Partial responseīy default, the server sends back the full representation of a resource after processing requests. More details on making partial requests are provided in the following sections. Patch: An update request where you send only the fields you want to change (use the PATCH HTTP verb).Partial response: A request where you specify which fields to include in the response (use the fields request parameter).This lets your application avoid transferring, parsing, and storing unneeded fields, so it can use resources including network, CPU, and memory more efficiently. Here is an example of properly formed HTTP headers for enabling gzip compression: Accept-Encoding: gzipĪnother way to improve the performance of your API calls is by sending and receiving only the portion of the data that you're interested in. In order to receive a gzip-encoded response you must do two things: Set an Accept-Encoding header, and modify your user agent to contain the string gzip. Although this requires additional CPU time to uncompress the results, the trade-off with network costs usually makes it very worthwhile. Compression using gzipĪn easy and convenient way to reduce the bandwidth needed for each request is to enable gzip compression. However, the same concepts are applicable to the Drive API. In some cases, examples from other APIs or generic APIs are used to illustrate the ideas presented. This document covers some techniques you can use to improve the performance of your application.
