This Python script queries the Gexbot API and downloads historical JSON data.
This script (main.py) is configured to query the Gexbot historical data endpoints. It will iterate through a user-defined list of tickers and data categories ("combos") for a specific date.
For each valid combination, the script requests a signed download URL, downloads the data directly, parses the JSON response, and prints a small preview.
Some historical responses may be gzip-compressed while others may already be plain JSON. The script checks the response bytes and only decompresses when the payload is actually gzip data.
Before running, you must configure the script:
The script requires a valid Gexbot API key. You can set this in one of two ways:
-
(Recommended) As an environment variable named
GEXBOT_API_KEY. -
Alternatively, you can paste your key directly into the
API_KEYvariable inmain.py:# main.py API_KEY = "YOUR_API_KEY_HERE"
The Gexbot API requires a User-Agent header. main.py intentionally defaults this value to an empty string so the script fails fast until you provide a client identifier.
# main.py
USER_AGENT = "AcmeQuantClient/1.0"Use a value that identifies your application, script, or organization.
Change the DATE_TO_QUERY variable to the YYYY-MM-DD date you wish to retrieve.
# main.py
DATE_TO_QUERY = "2025-11-14"Edit the ACTIVE_TICKERS and ACTIVE_*_CATEGORIES lists in main.py by uncommenting the symbols and feeds you want to query.
python main.pyIf GEXBOT_API_KEY or USER_AGENT is missing, the script will print an error and exit before making API requests.