TypeScript SDK
Reference for @predbooks/sdk: load days of data as Apache Arrow tables in Node, plus downloads, files, markets and caching.
API key. Pick a plan on Pricing and create a key, then install the SDK for your language: the Go SDK, Python SDK, Rust SDK or TypeScript SDK.
npm install @predbooks/sdkimport { Client } from "@predbooks/sdk";
const pb = new Client("pb_..."); // or { apiKey, baseUrl, cacheDir, timeout }The key can also come from PREDBOOKS_API_KEY. Every call returns a promise. The SDK needs Node 18 or newer.
Downloaded files are cached by version, so a file that was reprocessed is fetched again. The cache lives in PREDBOOKS_CACHE, or else in the user cache directory plus predbooks:
- Linux:
~/.cache/predbooks - macOS:
~/Library/Caches/predbooks - Windows:
%LOCALAPPDATA%\predbooks
load
const trades = await pb.load("kalshi", "trades", "2026-12-05");
const quotes = await pb.load("polymarket", "quotes", "2026-12-05", {
hours: [14, 15],
instruments: ["7179..."],
});
console.log(trades.numRows, trades.getChild("price")?.get(0));load returns one day of a channel as an apache-arrow Table.
| Option | Meaning |
|---|---|
hours | For hourly channels (book_delta, book_10, quotes): which hours, for example [13, 14]; default all |
instruments | Only these instrument ids. Read with HTTP range requests instead of downloading whole files |
columns | Only these columns |
decimals | "float" (default) turns prices and sizes into float64; "exact" keeps the stored decimals |
With decimals: "exact", prices and sizes are Arrow Decimal columns. Their values are unscaled integers, and the scale is in the column type. Int64 columns read as bigint.
Other calls
| Call | Returns |
|---|---|
pb.venues() | Venues, their channels, first and last dates, sizes |
pb.files(venue, channel, { start, end }) | Files with date, hour, size, rows, version and flags |
pb.markets(venue, { q, date, limit }) | Markets matching a question search or an exact market id, with their instrument_ids |
pb.download(venue, channel, date, hour?) | Path to the downloaded (or cached) Parquet file |
pb.link(venue, channel, date, hour?) | A signed download URL, valid for an hour |
pb.me() | Your plan and files used |
Errors reject with PredBooksError, which carries status, code and message:
import { PredBooksError } from "@predbooks/sdk";
try {
await pb.load("polymarket", "book_10", "2026-12-05", { hours: [14] });
} catch (e) {
if (e instanceof PredBooksError && e.code === "not_allowed") {
// this channel needs a higher plan
}
}Free data
markets and coverage need no key:
const pb = new Client();
await pb.load("kalshi", "markets", "2026-12-05");