roshi

Crates.ioroshi
lib.rsroshi
version0.0.1
created_at2025-08-02 18:33:55.552748+00
updated_at2025-08-02 18:33:55.552748+00
descriptionA Rust client for the Kalshi API
homepage
repositoryhttps://github.com/ElijahElrod/roshi
max_upload_size
id1779043
size93,033
Elijah Elrod (ElijahElrod)

documentation

README

Roshi β€” Kalshi SDK for Rust

Roshi is a fully asynchronous, type-safe, and ergonomic SDK for interacting with the Kalshi prediction market exchange.

This crate wraps both Kalshi’s REST and WebSocket APIs, providing a modern, Rust-native interface for trading, market data, and more.


Features

  • βœ… Full support for Kalshi's REST API
  • πŸ“‘ Real-time market data over Kalshi's WebSocket feeds
  • πŸ” API key authentication and request signing
  • 🧠 Typed models for events, markets, orders, and more
  • πŸ“¦ Built on reqwest, tokio, serde, and tokio-tungstenite

Quick Start

REST Client Example

use roshi::HttpClient;
use roshi::mode::Mode;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client = HttpClient::new(Mode::Demo, Some("your-api-key".to_string()), None);
    let markets = client.get_markets().await?;

    for market in markets.markets.unwrap_or_default() {
        println!("{} - {}", market.ticker.unwrap_or_default(), market.title.unwrap_or_default());
    }
    Ok(())
}

WebSocket Client Example

use roshi::WebSocketClient;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let mut ws = WebSocketClient::connect().await?;
    ws.subscribe_market("INFLATION2024").await?;

    while let Some(event) = ws.next_event().await {
        match event {
            roshi::WebSocketEvent::MarketUpdate(update) => println!("{:#?}", update),
            roshi::WebSocketEvent::Error(e) => eprintln!("WebSocket error: {:?}", e),
            _ => {}
        }
    }
    Ok(())
}

Modules

  • [client] β€” REST and WebSocket API support
  • [constants] β€” API Endpoints
  • [types] β€” Typed data structures for markets, events, orders, etc.
  • [utils] β€” Utility functions for signing, formatting, etc.

Crate Features

Enable optional features in your Cargo.toml:

[dependencies.roshi]
version = "0.1"
features = ["rest_client", "ws_client", "debug"]

License

Licensed

Commit count: 0

cargo fmt