| Crates.io | kalshi-rs |
| lib.rs | kalshi-rs |
| version | 0.2.1 |
| created_at | 2025-11-17 07:44:32.312365+00 |
| updated_at | 2026-01-12 22:21:30.945623+00 |
| description | Rust SDK for the Kalshi prediction market API. Mirrors the official Python SDK design for ease of use. |
| homepage | |
| repository | https://github.com/arnavchahal/kalshi-rs |
| max_upload_size | |
| id | 1936391 |
| size | 319,811 |
kalshi-rs is a Rust client that mirrors the structure and behavior of the
official Kalshi Python SDK
https://docs.kalshi.com/sdks/python/quickstart
This means:
If you’ve used Kalshi’s Python SDK, the Rust version will feel immediately familiar.
The crate supports:
The best way to get started is to look at the examples below, the examples in the examples directory and in the quickstart guide and for contirbutions and understanding how the repo is structured the /src readme
Add the crate to your project:
cargo add kalshi-rs
use kalshi_rs::{KalshiClient, Account};
use kalshi_rs::markets::models::MarketsQuery;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_key_id = std::env::var("KALSHI_API_KEY_ID")?;
let account = Account::from_file("kalshi_private.pem", api_key_id)?;
let client = KalshiClient::new(account);
let params = MarketsQuery {
status: Some("active".into()),
limit: Some(10),
..Default::default()
};
let markets = client.get_all_markets(¶ms).await?;
for m in markets.markets {
println!("{} — {}", m.ticker, m.title);
}
Ok(())
}
use kalshi_rs::portfolio::models::CreateOrderRequest;
let order = CreateOrderRequest {
ticker: "KXWTAMATCH".into(),
action: "buy".into(),
side: "yes".into(),
count: 1,
type_: Some("limit".into()),
yes_price: Some(3),
..Default::default()
};
let placed = client.create_order(&order).await?;
println!("Order ID: {}", placed.order.order_id);
client.cancel_order(placed.order.order_id.clone()).await?;
println!("Order canceled.");
Several tests interact with the real Kalshi API. You must set your environment variables:
export KALSHI_API_KEY_ID="your_key_id"
export KALSHI_PRIVATE_KEY_PATH="path/to/your/kalshi_private.pem"
You can generate these keys from the Kalshi dashboard:
API Keys Setup: API keys setup
Then run:
cargo test -- --nocapture
Tests involving trading endpoints will make real requests, so be mindful of costs.
kalshi-rs intentionally follows the official Python SDK’s structure and naming to make the transition between languages seamless. If the Python docs say:
client.markets.get_markets(...)
You can expect the Rust version to expose an equivalent:
client.get_all_markets(...)
The goal is clarity, reliability, and easy adoption — not reinvention.
Contributions are welcome!
If you're implementing newly released Kalshi endpoints, improving error handling, or adding examples, all PRs are appreciated.
This project is licensed under the MIT License.
See LICENSE for details.