SDK
Quickstart
Install the SDK and make your first request
SDK Quickstart
This guide walks you through installing the PAPI SDK and fetching your first market data.
Prerequisites
- Rust 1.83 or later
- A PAPI API key (get one at dashboard.tylerthebuildor.com)
Installation
Create a new project and add the SDK:
cargo new my-papi-app
cd my-papi-app[dependencies]
papi-sdk = "0.1"
tokio = { version = "1", features = ["full"] }Fetch Markets
use papi_sdk::{PapiConfig, PapiClient, Exchange};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Configure managed mode with your API key
let config = PapiConfig::managed()
.api_key("papi_sk_live_a1b2c3d4e5f6...")
.build()?;
let client = PapiClient::new(config);
// List active Polymarket markets
let markets = client
.markets(Exchange::Polymarket)
.active(true)
.limit(5)
.send()
.await?;
for market in &markets {
println!("[{}] {}", market.exchange, market.title);
for outcome in &market.outcomes {
println!(" {} — {}", outcome.name, outcome.price);
}
}
Ok(())
}Run it:
cargo runExpected output:
[Polymarket] Will BTC reach $100k by end of 2026?
Yes — 0.62
No — 0.38
[Polymarket] US Presidential Election Winner 2028
Republican — 0.51
Democrat — 0.45
Other — 0.04Search Markets
Search across exchanges by keyword:
let results = client
.markets(Exchange::Polymarket)
.search("bitcoin")
.active(true)
.send()
.await?;Fetch from Kalshi
Switch exchanges by changing the enum:
let kalshi_markets = client
.markets(Exchange::Kalshi)
.status("open")
.limit(10)
.send()
.await?;Use Environment Variables
Instead of hardcoding your API key:
export PAPI_API_KEY=papi_sk_live_a1b2c3d4e5f6...let config = PapiConfig::managed()
.api_key_from_env() // reads PAPI_API_KEY
.build()?;Next Steps
- Configuration — All environment variables and config options
- Managed Mode — How managed mode works under the hood
- Trading — Place orders through the API