Data Compression
Use of Gzip Compression by the API
Some large API responses are automatically compressed with gzip to reduce size and speed up downloads.
Accepting Gzipped Responses
Most HTTP clients and browsers support gzip by default. To ensure gzip is accepted, add the following header to your request:
1Accept-Encoding: gzip
If the response is large, the server will send it gzipped.
Reading Gzipped Responses
- Browsers: Handled automatically.
- curl: Use
--compressed:1curl --compressed https://api.example.com/data - Code: If not automatic, check
Content-Encoding: gzipand decompress with your language's gzip/zlib library.
Small responses may not be gzipped, this is normal.
Sending Gzipped Request Data
If your request body is large (greater than 6MB), you should also compress it before sending. To do this:
- Compress your request body using gzip.
- Add the following header to indicate compression:
1Content-Encoding: gzip - Our server endpoints automatically decompress gzipped request bodies.
Example with curl:
1echo '{"large":"payload"}' | gzip | curl -X POST https://api.example.com/upload -H 'Content-Encoding: gzip' -H 'Content-Type: application/json' --data-binary @-
This helps reduce upload size for large JSON or binary payloads.
You can read more about Compression in HTTP & gzip compression in the MDN Web Docs.