SDK
SDK Overview
Rust SDK for unified prediction market access
PAPI SDK
The PAPI SDK is a Rust library that provides unified access to prediction markets. It supports two modes of operation and normalizes data across exchanges into a consistent interface.
Repository: github.com/tylerthebuildor/papi-sdk-rs
Installation
Add to your Cargo.toml:
[dependencies]
papi-sdk = "0.1"
tokio = { version = "1", features = ["full"] }Managed vs Direct Mode
Managed Mode
In managed mode, all requests go through the PAPI API at papi.tylerthebuildor.com. The API handles:
- Authentication — Your API key authenticates with PAPI; exchange credentials are stored encrypted server-side
- Caching — Market data is cached with short TTLs (5-60s) to reduce exchange API load
- Rate Limiting — 60 requests per minute per API key
- Unified Responses — Consistent JSON format across exchanges
This is the recommended mode for most users. You never handle exchange credentials directly.
Direct Mode
In direct mode, the SDK connects directly to exchange APIs. You provide exchange credentials locally and no data passes through PAPI servers. This mode is for users who:
- Need lower latency (no proxy hop)
- Want full control over their credentials
- Are running in environments where they can securely store API keys
Core Types
The SDK normalizes exchange-specific data into shared types:
// Unified market representation
pub struct Market {
pub id: String,
pub exchange: Exchange,
pub title: String,
pub status: MarketStatus,
pub outcomes: Vec<Outcome>,
// ...
}
pub enum Exchange {
Polymarket,
Kalshi,
}
pub enum MarketStatus {
Active,
Closed,
Settled,
}Next Steps
- Quickstart — First working example in 2 minutes
- Configuration — All config options and environment variables
- Managed Mode — Deep dive into managed mode
- Direct Mode — Deep dive into direct mode