DocsTypeScript SDK

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.

Terminal
npm install @predbooks/sdk
TypeScript
import { 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

TypeScript
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.

OptionMeaning
hoursFor hourly channels (book_delta, book_10, quotes): which hours, for example [13, 14]; default all
instrumentsOnly these instrument ids. Read with HTTP range requests instead of downloading whole files
columnsOnly 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

CallReturns
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:

TypeScript
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:

TypeScript
const pb = new Client();
await pb.load("kalshi", "markets", "2026-12-05");