> ## 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.18.0"
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 |

> [card] [V3 API](https://docs.polynode.dev/sdks/rust/v3-api.md)
>
> Call any registered V3 operation.

> [card] [Settlement stream](https://docs.polynode.dev/sdks/rust/websocket.md)
>
> Subscribe with replay and backpressure.

> [card] [Short-form and TWAP](https://docs.polynode.dev/sdks/rust/short-form.md)
>
> Rotate with the correct Chainlink window.

> [card] [PN1 orderbook](https://docs.polynode.dev/sdks/rust/orderbook.md)
>
> Maintain fail-closed local state.

> [card] [Perps stream](https://docs.polynode.dev/sdks/rust/perps.md)
>
> Subscribe to tickers, books, trades, and klines.

> [card] [Trading and fees](https://docs.polynode.dev/sdks/rust/trading.md)
>
> Enable the trading feature and use V2 defaults.

> [card] [Connect Wallet to order](https://docs.polynode.dev/sdks/user-owned-web-app.md)
>
> Use Rust behind a browser-signing flow.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.