Download Chainlink BTC/USD price and TWAP60 history with Python

Updated 2026-11-09

Guides

To download recorded Chainlink BTC historical data in Python, use Poly Tick Tape’s API to list daily BTC/USD price and TWAP60 files, download the gzip JSONL files, and verify their SHA-256 hashes. Keep prices as decimal strings and timestamps in UTC. Full-day downloads require paid access; the home page has a free 10-minute preview.

Choose the recorded stream

Poly Tick Tape independently records two published Chainlink streams: BTC/USD price and BTC/USD TWAP 60s. The price dataset records the former; twap60 records the latter. TWAP60 is supplied by Chainlink, not calculated locally from the archived price rows. These are recorded observations, not a guarantee of every upstream update.

Use price to study the price stream and twap60 when your analysis calls for the published trailing 60-second average. The TWAP60 guide explains that distinction. For Polymarket research, consult the five-minute settlement guide before selecting an input.

The archive starts on 2026-08-14. Each stream has a separate file per UTC day, named btc-price-YYYY-MM-DD.jsonl.gz or btc-twap60-YYYY-MM-DD.jsonl.gz. The recording methodology describes collection and gaps; the API documentation defines the file format.

Inspect availability before using a key

  1. Open the free 10-minute home-page preview, covering 2026-09-20 04:35–04:45 UTC. It shows the data format; it is not free access to arbitrary historical days.
  2. Check the unauthenticated public catalog for published dates and stream statistics. Catalog visibility does not grant download permission. Compare available dates with the period you need, then review pricing.
  3. Read the refund policy before your first authenticated API request. API access may affect refund eligibility; an access check is still an authenticated request. Decide whether to proceed before sending a key.

The catalog and preview let you inspect the product before crossing that boundary. Do not assume that an account’s purchased period, subscription window and the full published archive are identical.

List and download daily files

Install requests with python3 -m pip install requests, save the following as download.py, and set the POLYTICKTAPE_KEY environment variable to your API key. Keep the key out of source control and query strings. Authenticated requests use an Authorization: Bearer header.

First call GET /v1/access with that header. Check its ranges and lastPublished against your target dates. Then use GET /v1/days with from, to and streams. Both date endpoints are inclusive, and a listing request supports at most 92 calendar days; split longer ranges.

This shared downloader requests both streams for 2026-08-14 through 2026-08-20, matching the documentation example:

download.py
import hashlib
import os
import pathlib

import requests

BASE = "https://polyticktape.com"
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['POLYTICKTAPE_KEY']}"


def download(date_from, date_to, streams="price,twap60", out="data"):
    r = session.get(f"{BASE}/v1/days", params={"from": date_from, "to": date_to, "streams": streams})
    r.raise_for_status()
    listing = r.json()
    files = [day[s] for day in listing["days"] for s in listing["streams"] if s in day]
    for f in files:
        path = pathlib.Path(out) / f["name"]
        if path.exists() and hashlib.sha256(path.read_bytes()).hexdigest() == f["sha256"]:
            continue  # already downloaded; don't spend quota on it again
        body = session.get(f["url"]).content  # follows the redirect to a short-lived signed link
        if hashlib.sha256(body).hexdigest() != f["sha256"]:
            raise ValueError(f"checksum mismatch: {f['name']}")
        path.parent.mkdir(parents=True, exist_ok=True)
        path.write_bytes(body)
        print("saved", path)
    for m in listing["missing"]:
        print("missing", m["date"], m["stream"], m["reason"])


download("2026-08-14", "2026-08-20")

Run it with python3 download.py. It lists files, reuses local files whose hashes match, follows download redirects, verifies downloaded bytes and prints missing entries. The listing contains authenticated download endpoints; those redirect to temporary signed links. If a signed link expires, request the authenticated endpoint again. See the machine-readable API reference for authentication, responses and download limits.

Finishing this script does not prove that the requested range is complete. Its file comprehension skips stream entries absent from listing["days"]. Compare returned dates and streams, plus listing["missing"], with every date/stream pair requested. A date with neither stream can appear only in missing. Investigate not_entitled and not_published rather than silently shrinking your research period.

Save the listing alongside your research inputs so you can later identify the requested range, file names and expected hashes. Review each file’s records and coverage too: available files can still contain missing seconds.

Read JSONL without losing precision

Each gzip file contains UTF-8 JSON Lines: one JSON object per recorded row, ordered by ts, with at most one row per second. Missing seconds remain missing; the archive does not insert replacement prices.

Field Data type Use
ts Integer Quote’s Unix second; interpret in UTC
p String Decimal price preserving the supplied digits
v Float Floating-point representation for approximate numerical work
feed_ts_ms Integer Quote timestamp in milliseconds
server_ts_ms Integer or null Upstream sending timestamp, when available
recv_ms Integer Collector receipt timestamp in milliseconds
lag Integer recv_ms - feed_ts_ms, in milliseconds

Install pandas to load the downloaded TWAP60 example:

read.py
import pandas as pd

df = pd.read_json("data/btc-twap60-2026-08-14.jsonl.gz", lines=True, dtype=False, convert_dates=False)
df["time"] = pd.to_datetime(df["ts"], unit="s", utc=True)
# ts, lag and the *_ms columns are integers, p is a string, v is a float

The loader preserves p as a string and creates a UTC time column from ts. For exact comparisons, construct Python Decimal values directly from p, using sufficient decimal precision for subsequent arithmetic. Converting through v first cannot recover digits lost to floating point. Use v when approximate numerical work is appropriate.

Check boundaries and interpret the limits

For a five-minute round ending at 00:00:00 UTC, the final boundary belongs to the next day’s file. Download that next day as well, and require the exact boundary second. A nearby row is not the same observation. If either boundary is missing, flag the round instead of silently forward-filling it. The BTC backtesting guide covers the broader research workflow.

A matching SHA-256 establishes that your local bytes match the listed file. It does not establish market truth, complete upstream capture, complete requested coverage or the validity of a trading strategy. Timestamp and coverage checks answer different questions from a checksum. This archive supports historical analysis; it is not a live execution feed. For uncertainty about a period or missing file, contact support with the UTC dates and stream names.

Sources

More guides

Not affiliated with Polymarket or Chainlink. Not investment advice.