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

# SDKs

> Official client libraries for the PolyNode API

PolyNode provides official SDKs for TypeScript, Rust, and Python. All wrap the full REST API and WebSocket streaming interface with typed responses, auto-reconnection, and zlib compression support.

<CardGroup cols={2}>
  <Card title="TypeScript / Node.js" icon="js" href="/sdks/typescript">
    `npm install polynode-sdk`

    Zero runtime dependencies. ESM + CJS. Node 18+.
  </Card>

  <Card title="Rust" icon="rust" href="/sdks/rust">
    `polynode = "0.12"`

    Async with tokio. Typed events via serde.
  </Card>

  <Card title="Python" icon="python" href="/sdks/python">
    `pip install polynode`

    Sync + async. Pydantic v2 types. Python 3.10+.
  </Card>

  <Card title="Charts (Browser)" icon="chart-line" href="/charts/overview">
    `npm install polynode-charts`

    Zero-dependency Canvas 2D charting for prediction markets and live crypto prices. Browser only.
  </Card>
</CardGroup>

<Note>
  **`polynode-sdk`** is the data SDK (REST, WebSocket, trading, cache). It runs in Node.js.

  **`polynode-charts`** is the visualization SDK (candlestick charts, orderbooks, live streaming UI). It runs in the browser.

  Building a frontend? Install both: `npm install polynode-sdk polynode-charts`
</Note>

## Features

<CardGroup cols={2}>
  <Card title="Local Cache" icon="database" href="/sdks/local-cache">
    SQLite-backed local storage. Backfill wallet history in seconds, query trades and positions instantly with zero API calls.
  </Card>

  <Card title="Short-Form Markets" icon="clock" href="/sdks/short-form">
    Auto-rotating streams for 5m, 15m, and 1h crypto prediction markets. Includes price-to-beat, odds, and liquidity.
  </Card>

  <Card title="WebSocket Streaming" icon="bolt" href="/sdks/websocket-streaming">
    Builder-pattern subscriptions with 10 presets, 11 filter dimensions, and transparent compression.
  </Card>

  <Card title="Orderbook" icon="layer-group" href="/sdks/orderbook">
    Real-time orderbook data with local state management, filtered views, and 108k+ markets.
  </Card>

  <Card title="REST API" icon="globe" href="/sdks/rest-api">
    Typed methods for all 25 REST endpoints. Markets, pricing, settlements, wallets, enriched data.
  </Card>

  <Card title="RPC Proxy" icon="plug" href="/sdks/rpc">
    JSON-RPC through PolyNode's optimized Polygon endpoint with validator-targeted TX submission.
  </Card>

  <Card title="Redemption Watcher" icon="bell" href="/sdks/redemption-watcher">
    Push alerts when tracked wallets' positions become redeemable. Combines REST positions with real-time oracle events.
  </Card>

  <Card title="Trading" icon="arrow-right-arrow-left" href="/sdks/trading">
    Place orders on Polymarket with one-call gasless onboarding. Auto-detects wallet type, local credential custody, builder attribution.
  </Card>
</CardGroup>

## What the SDKs Cover

| Feature                                         | TypeScript          | Rust                     | Python              |
| ----------------------------------------------- | ------------------- | ------------------------ | ------------------- |
| Local cache (SQLite)                            | Yes                 | Yes                      | Planned             |
| REST API (25 endpoints)                         | Yes                 | Yes                      | Yes                 |
| WebSocket streaming                             | Yes                 | Yes                      | Yes (async)         |
| Short-form markets (auto-rotation)              | Yes                 | Yes                      | Yes                 |
| All 9 event types + price feeds                 | Typed interfaces    | Typed structs + enum     | Pydantic models     |
| Subscription filters                            | Builder pattern     | Builder pattern          | Builder pattern     |
| Orderbook streaming                             | Yes                 | Yes                      | Yes                 |
| Local orderbook state                           | `LocalOrderbook`    | `LocalOrderbook`         | `LocalOrderbook`    |
| OrderbookEngine (views)                         | Yes                 | Yes                      | Yes                 |
| Zlib compression                                | Transparent         | Transparent              | Transparent         |
| Auto-reconnect                                  | Exponential backoff | Exponential backoff      | Exponential backoff |
| Enriched data (leaderboard, trending, profiles) | Yes                 | Yes                      | Yes                 |
| RPC proxy                                       | Yes                 | Yes                      | Yes                 |
| Redemption watcher                              | Yes                 | Yes                      | Yes                 |
| Trading (order placement)                       | Yes                 | Yes (feature: `trading`) | Yes                 |

## Quick Comparison

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    import { PolyNodeWS } from 'polynode-sdk';

    const ws = new PolyNodeWS('pn_live_...', 'wss://ws.polynode.dev/ws');

    // Short-form: auto-rotating 15m crypto markets
    const stream = ws.shortForm('15m', { coins: ['btc', 'eth'] });
    stream.on('rotation', (r) => {
      for (const m of r.markets) {
        console.log(`${m.coin}: beat $${m.priceToBeat} | ${(m.upOdds * 100).toFixed(0)}% up`);
      }
    });
    stream.on('settlement', (e) => console.log(e.outcome, e.taker_size));

    // Manual subscription
    const sub = await ws.subscribe('settlements')
      .minSize(1000)
      .send();
    sub.on('settlement', (e) => console.log(e.taker_side, e.taker_size));
    ```
  </Tab>

  <Tab title="Rust">
    ```rust theme={null}
    use polynode::{PolyNodeClient, ShortFormInterval, ShortFormMessage, Coin};

    let client = PolyNodeClient::new("pn_live_...")?;

    // Short-form: auto-rotating 15m crypto markets
    let mut stream = client
        .short_form(ShortFormInterval::FifteenMin)
        .coins(&[Coin::Btc, Coin::Eth])
        .start().await?;

    while let Some(msg) = stream.next().await {
        match msg {
            ShortFormMessage::Rotation(r) => {
                for m in &r.markets {
                    println!("{}: beat ${:?} | {:.0}% up",
                        m.coin.id(), m.price_to_beat, m.up_odds * 100.0);
                }
            }
            ShortFormMessage::Event(e) => println!("{:?}", e),
            ShortFormMessage::Error(e) => eprintln!("{}", e),
        }
    }
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import asyncio
    from polynode import AsyncPolyNode

    async def main():
        async with AsyncPolyNode(api_key="pn_live_...") as pn:
            # Subscribe to settlements with filters
            sub = await pn.ws.subscribe("settlements") \
                .min_size(1000) \
                .status("all") \
                .send()

            async for event in sub:
                print(f"{event.taker_side} ${event.taker_size:.0f} on {event.market_title}")
                print(f"  status: {event.status}, price: {event.taker_price}")

    asyncio.run(main())
    ```
  </Tab>
</Tabs>

## Don't Need an SDK?

The PolyNode API uses standard HTTP and WebSocket protocols. You can use any HTTP client or WebSocket library directly. See the [Quickstart](/quickstart) for raw examples in cURL, Python, and JavaScript.
