> ## Documentation Index
> Fetch the complete documentation index at: https://docs.polynode.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Rust SDK

> Install polynode 0.17 and make a first V3 request with Tokio.

The Rust crate provides Tokio clients for the complete V3 registry, event streaming, PN1 orderbooks, perps, short-form markets, and optional trading and cache features.

## Install

```toml Cargo.toml theme={null}
[dependencies]
polynode = "0.17.1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
```

Keep the key outside source control:

```bash theme={null}
export POLYNODE_API_KEY="pn_live_..."
```

## First request

```rust theme={null}
use polynode::{PolyNodeClient, V3RequestOptions};

#[tokio::main]
async fn main() -> polynode::Result<()> {
    let api_key = std::env::var("POLYNODE_API_KEY")
        .expect("Set POLYNODE_API_KEY");
    let client = PolyNodeClient::new(api_key)?;
    let stats = client
        .v3()
        .execute_named("GET /v3/stats", V3RequestOptions::default())
        .await?;
    println!("{stats:#}");
    Ok(())
}
```

## Client surfaces

| Entry point                     | Use it for                                                             |
| ------------------------------- | ---------------------------------------------------------------------- |
| `client.v3()`                   | Complete V3 API registry                                               |
| `client.stream(...)`            | Settlements, confirmations, Chainlink prices, combos, and other events |
| `client.orderbook_stream(...)`  | Raw orderbook messages                                                 |
| `OrderbookEngine::connect(...)` | Managed local books and PN1 integrity                                  |
| `client.perps_stream()`         | Managed V3 perps WebSocket                                             |
| `client.short_form(...)`        | Rotating 5m, 15m, 1h, and 4h crypto markets                            |
| `PolyNodeTrader`                | Current V2 trading with the `trading` feature                          |

<CardGroup cols={2}>
  <Card title="V3 API" icon="database" href="/sdks/rust/v3-api">Call any registered V3 operation.</Card>
  <Card title="Settlement stream" icon="bolt" href="/sdks/rust/websocket">Subscribe with replay and backpressure.</Card>
  <Card title="Short-form and TWAP" icon="clock" href="/sdks/rust/short-form">Rotate with the correct Chainlink window.</Card>
  <Card title="PN1 orderbook" icon="book-open" href="/sdks/rust/orderbook">Maintain fail-closed local state.</Card>
  <Card title="Perps stream" icon="chart-line" href="/sdks/rust/perps">Subscribe to tickers, books, trades, and klines.</Card>
  <Card title="Trading and fees" icon="arrow-right-arrow-left" href="/sdks/rust/trading">Enable the trading feature and use V2 defaults.</Card>
  <Card title="Connect Wallet to order" icon="browser" href="/sdks/user-owned-web-app">Use Rust behind a browser-signing flow.</Card>
</CardGroup>
