Examples

# Required package requests: `pip install requests`

import json
import base64
import requests
                    
# Using of Client Credentials authorization flow.
# Insert your client credentials received in welcome email.

client_id = "your_client_id"
client_secret = "your_client_secret"

identity_url = "https://id.livevol.com/connect/token"
api_url = "https://api.livevol.com/v1/delayed/allaccess/market/underlying-quotes?symbols=AAPL&date=2019-01-18"

authorization_token  = base64.b64encode((client_id + ':' + client_secret).encode())
headers = {"Authorization": "Basic " + authorization_token.decode('ascii')}
payload = {"grant_type": "client_credentials"}

# Requesting access token
token_data = requests.post(identity_url, data=payload, headers=headers)

if token_data.status_code == 200:
    access_token = token_data.json()['access_token']
    if len(access_token) > 0:
        print("Authenticated successfully")
        
		# Requesting data from API
        result = requests.get(api_url, headers={"Authorization": "Bearer " + access_token})
        print(result.json())
else:
    print("Authentication failed")

Compressing responses with gzip

Responses are returned gzip-compressed whenever the request carries an Accept-Encoding: gzip header. On large payloads the saving is substantial: a full ^SPX option chain from option-and-underlying-quotes transfers as roughly 1.8 MB instead of 16.5 MB — about a 9× reduction. The decoded body is byte-for-byte identical either way.

Only gzip is supported. A request advertising only br (Brotli) or only deflate receives the full uncompressed response — silently, with no error. Include gzip in the list; a combined value such as br, gzip negotiates down correctly. To confirm it worked, check that the response carries Content-Encoding: gzip. Some clients hide that header: .NET HttpClient and axios remove it after decoding, and a browser hides it on cross-origin calls. In those cases check with curl (see the C# or JavaScript example).

Most HTTP clients request and decode gzip for you automatically. The notable exceptions are C# and Java's built-in java.net.http.HttpClient, which need to be configured explicitly — select your language above.

# requests already sends `Accept-Encoding: gzip, deflate` and decodes the
# response for you, so no configuration is required.

result = requests.get(api_url, headers={"Authorization": "Bearer " + access_token})

print(result.headers.get("Content-Encoding"))   # -> 'gzip'

# CAUTION: len(result.content) is the DECODED size, not the bytes received.
# Measuring it will make a compressed response look uncompressed.
print(len(result.content))                      # ~16,970,000 (decoded)

# To see what actually crossed the network, read the raw stream:
raw = requests.get(api_url,
                   headers={"Authorization": "Bearer " + access_token},
                   stream=True)
print(len(raw.raw.read()))                      # ~1,860,000 (on the wire)