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

# TypeScript SDK

> Install polynode-sdk 0.14 and make a first V3 request from Node.js.

`polynode-sdk` is the Node.js client for Polynode's V3 API, event stream, PN1 orderbook, perps stream, short-form markets, and trading helpers.

## Install

```bash theme={null}
npm install polynode-sdk@^0.14.2 ws
```

Node.js 18 or newer is required. The package supports ESM imports and CommonJS runtime loading. The examples use ESM.

```json package.json theme={null}
{
  "type": "module"
}
```

Keep your key server-side:

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

## First request

```typescript theme={null}
import { PolyNode } from 'polynode-sdk';

const apiKey = process.env.POLYNODE_API_KEY;
if (!apiKey) throw new Error('Set POLYNODE_API_KEY');

const pn = new PolyNode({ apiKey });
const stats = await pn.v3.stats();
console.log(stats);
```

## Client surfaces

| Entry point                | Use it for                                                             |
| -------------------------- | ---------------------------------------------------------------------- |
| `pn.v3`                    | Complete V3 API registry and typed convenience methods                 |
| `pn.ws`                    | Settlements, confirmations, Chainlink prices, combos, and other events |
| `pn.orderbook`             | Raw orderbook messages                                                 |
| `new OrderbookEngine(...)` | Managed local books and PN1 integrity                                  |
| `pn.perps`                 | Managed V3 perps WebSocket                                             |
| `pn.ws.shortForm(...)`     | Rotating 5m, 15m, 1h, and 4h crypto markets                            |
| `new PolyNodeTrader(...)`  | Current V2 order and position operations                               |

Each WebSocket is independent. Close the subscription or client you opened when your process shuts down.

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