Introducing

Speed Up Downloads: Gzip Compression for Polygon's API

Mar 28, 2023

In our continuous effort to improve user experience, we've enabled gzip compression by default in our latest Python and Golang client libraries. In this blog, we'll explore the advantages of using gzip compression, and how you can implement it using Python, Go, and cURL.

Why It Matters

Gzip compression significantly reduces the amount of data transferred during downloads, resulting in quicker and more efficient downloads. By compressing your market data, you can save bandwidth and reduce the latency of your data processing pipeline. It's a win-win situation for developers and traders alike.

Getting Started with Python

To take advantage of gzip compression in Python, simply update to the latest version of the Polygon's Python client library. You can do this by running:

pip install polygon-api-client --upgrade

With the updated library, gzip compression will be enabled by default, allowing you to experience faster downloads without making any code changes.

Getting Started with Go

For Golang users, update to the latest version of the Polygon's Go client library to enable gzip compression by default. To update, run:

go get github.com/polygon-io/client-golang

With the latest library, you'll enjoy the benefits of gzip compression without having to modify your existing code.

Getting started with JVM

For those using Polygon's client libraries with JVM languages like Java, Kotlin, or Scala, we have great news! Gzip compression support has already been added and is enabled by default. This means you don't have to worry about any additional setup or configuration to take advantage of faster downloads and reduced latency. Simply use the latest version of the JVM client library and enjoy the benefits of gzip compression with no extra effort.

Adding the Header Manually via cURL

If you prefer to test manually using cURL to access the REST API, you can add the

--compressed
option which adds the
"Accept-Encoding: gzip"
header to enable gzip compression. To do this, include the following flag in your cURL request (optionally add
-v
to show the headers):

curl --compressed [API_ENDPOINT]

Replace [API_ENDPOINT] with the desired API endpoint. The curl command will decompress the response on-the-fly, allowing you to process the data as usual.

Next Steps

We hope you found this guide useful in optimizing your market data downloads. Staying up-to-date with the latest versions of our client libraries ensures you have access to the most recent features and improvements. Enjoy faster downloads, lower latency, and an overall better experience with gzip compression on Polygon.io's REST API.

From the blog

See what's happening at polygon.io

case study fey Feature Image

Case Study: Fey

Discover how Fey, a rising star in fintech, transformed their financial application's capabilities with Polygon.io's API services. Dive into our latest case study to see how we're powering innovation in finance.