Rust SDK
Reference for the predbooks crate: load days of data as Arrow record batches, 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.
cargo add predbooksuse predbooks::{Client, LoadOptions};
let pb = Client::builder().api_key("pb_...").build()?;Client::new() reads everything from the environment:
- the key from
PREDBOOKS_API_KEY; - the base URL from
PREDBOOKS_API_URL; - the cache from
PREDBOOKS_CACHE.
The builder sets .api_key(), .base_url(), .cache_dir() and .timeout(). The timeout defaults to 120 s per connect or read.
The client is blocking. From async code, wrap calls in tokio::task::spawn_blocking.
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
let trades = pb.load("kalshi", "trades", "2026-12-05", LoadOptions::new())?;
let quotes = pb.load(
"polymarket",
"quotes",
"2026-12-05",
LoadOptions::new().hours([14, 15]).instruments(["7179..."]),
)?;
for batch in quotes.batches() {
println!("{} rows", batch.num_rows());
}load returns one day of a channel as a Table: the schema plus Arrow RecordBatches from the arrow crate, which predbooks::arrow re-exports. Table has batches(), into_batches(), num_rows() and concat().
| Option | Meaning |
|---|---|
.hours(...) | For hourly channels (book_delta, book_10, quotes): which hours; default all |
.instruments(...) | Only these instrument ids. Read with HTTP range requests instead of downloading whole files |
.columns(...) | Only these columns |
.decimals(...) | Decimals::Float (default) turns prices and sizes into float64; Decimals::Exact keeps Decimal128 |
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; start and end are Option<&str> |
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 are predbooks::Error. Errors from the API are Error::Api { status, code, message }, and .status() and .code() read them from any error:
match pb.load("polymarket", "book_10", "2026-12-05", LoadOptions::new().hours([14])) {
Err(e) if e.code() == Some("not_allowed") => { /* this channel needs a higher plan */ }
other => { other?; }
}Free data
markets and coverage need no key:
let pb = Client::new()?;
let markets = pb.load("kalshi", "markets", "2026-12-05", LoadOptions::new())?;