Go SDK
Reference for the predbooks Go module: load days of data as Arrow tables, 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.
go get predbooks.com/gopb := predbooks.New(predbooks.WithAPIKey("pb_..."))The key can also come from PREDBOOKS_API_KEY. Every call takes a context.Context.
The options for New are:
WithAPIKey;WithBaseURL, or setPREDBOOKS_API_URL;WithCacheDir;WithTimeout: 120 s per API call by default. Downloads are bounded by the context instead.WithHTTPClient.
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
ctx := context.Background()
trades, err := pb.Load(ctx, "kalshi", "trades", "2026-12-05", nil)
if err != nil {
log.Fatal(err)
}
defer trades.Release()
quotes, err := pb.Load(ctx, "polymarket", "quotes", "2026-12-05", &predbooks.LoadOptions{
Hours: []int{14, 15},
Instruments: []string{"7179..."},
})
if err != nil {
log.Fatal(err)
}
defer quotes.Release()Load returns one day of a channel as an arrow.Table from Apache Arrow for Go (arrow-go v18). Call Release on it when you are done.
| Field | Meaning |
|---|---|
Hours | For hourly channels (book_delta, book_10, quotes): which hours; nil means all |
Instruments | Only these instrument ids. Read with HTTP range requests instead of downloading whole files |
Columns | Only these columns, in that order |
ExactDecimals | Keep the stored decimals; by default prices and sizes become float64 |
The hours of a day are joined into one table. They must share a schema: a column missing from one hour is an error, not filled with nulls.
Other calls
| Call | Returns |
|---|---|
pb.Venues(ctx) | Venues, their channels, first and last dates, sizes |
pb.Files(ctx, venue, channel, start, end) | Files with Date, Hour, Size, Rows, Version and Flags; start and end may be empty |
pb.Markets(ctx, venue, &predbooks.MarketsOptions{Q, Date, Limit}) | Markets matching a question search or an exact market id, with their InstrumentIDs |
pb.Download(ctx, venue, channel, date[, hour]) | Path to the downloaded (or cached) Parquet file |
pb.Link(ctx, venue, channel, date[, hour]) | A signed download URL, valid for an hour |
pb.Me(ctx) | Your plan and files used |
Errors from the API are *predbooks.Error, with Status, Code and Message:
var e *predbooks.Error
if errors.As(err, &e) && e.Code == "not_allowed" {
// this channel needs a higher plan
}Free data
markets and coverage need no key:
pb := predbooks.New()
markets, err := pb.Load(ctx, "kalshi", "markets", "2026-12-05", nil)