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

# Crypto Prices

> Stream Chainlink spot prices and 30-second or 60-second TWAP prices over WebSocket.

Stream real-time Chainlink prices over WebSocket. Seven feeds update at
approximately one event per second each.

> [!NOTE]
>
> The default `chainlink` subscription now delivers both the 30-second and
> 60-second TWAP streams. Add `price_source: "spot"` to select spot prices
> explicitly. See [Chainlink Spot and TWAP Prices](https://docs.polynode.dev/crypto/twap.md) for every
> selection and its acknowledgement.

## Connection

```
wss://ws.polynode.dev/ws?key=YOUR_API_KEY
```

This is the same WebSocket endpoint used for settlements and orderbook. If you already have a connection open, you don't need a new one.

## Available feeds

| Feed | Pair | Update rate |
| - | - | - |
| `BTC/USD` | Bitcoin / US Dollar | \~1/second |
| `ETH/USD` | Ethereum / US Dollar | \~1/second |
| `SOL/USD` | Solana / US Dollar | \~1/second |
| `BNB/USD` | BNB / US Dollar | \~1/second |
| `XRP/USD` | XRP / US Dollar | \~1/second |
| `DOGE/USD` | Dogecoin / US Dollar | \~1/second |
| `HYPE/USD` | Hyperliquid / US Dollar | \~1/second |

## Quick start

Connect and follow the default stream for all seven feeds:

```javascript JavaScript theme={null}
const WebSocket = require("ws");

const ws = new WebSocket(
  "wss://ws.polynode.dev/ws?key=YOUR_API_KEY"
);

ws.on("open", () => {
  ws.send(JSON.stringify({
    action: "subscribe",
    type: "chainlink"
  }));
});

ws.on("message", (data) => {
  const msg = JSON.parse(data);
  if (msg.type === "price_feed") {
    console.log(`${msg.data.feed}: $${msg.data.price}`);
  }
});
```

```python Python theme={null}
import asyncio
import json
import websockets

async def main():
    uri = "wss://ws.polynode.dev/ws?key=YOUR_API_KEY"
    async with websockets.connect(uri) as ws:
        await ws.send(json.dumps({
            "action": "subscribe",
            "type": "chainlink"
        }))
        async for message in ws:
            msg = json.loads(message)
            if msg.get("type") == "price_feed":
                d = msg["data"]
                print(f"{d['feed']}: ${d['price']}")

asyncio.run(main())
```

```rust Rust theme={null}
use polynode::PolyNodeWS;

#[tokio::main]
async fn main() {
    let mut ws = PolyNodeWS::connect("YOUR_API_KEY").await.unwrap();
    ws.subscribe_price_feeds(None).await.unwrap(); // None = all feeds

    while let Some(event) = ws.next_event().await {
        println!("{}: ${}", event.feed, event.price);
    }
}
```

```bash wscat theme={null}
wscat -c "wss://ws.polynode.dev/ws?key=YOUR_API_KEY"

# Then send:
{"action": "subscribe", "type": "chainlink"}
```

### Filter to specific feeds

Only receive the feeds you care about:

```json theme={null}
{
  "action": "subscribe",
  "type": "chainlink",
  "filters": {
    "feeds": ["BTC/USD", "ETH/USD"]
  }
}
```

Omit `feeds` to get all 7.

### Select spot explicitly

Add `price_source: "spot"` to receive spot prices instead of following the
default TWAP stream:

```json theme={null}
{
  "action": "subscribe",
  "type": "chainlink",
  "filters": {
    "feeds": ["BTC/USD", "ETH/USD"],
    "price_source": "spot"
  }
}
```

Omit `feeds` to receive every available spot pair. Do not combine
`price_source: "spot"` with `twap_windows`.

## Event format

Every price update arrives as a `price_feed` event:

```json theme={null}
{
  "type": "price_feed",
  "feed": "BTC/USD",
  "timestamp": 1774672588,
  "is_twap": true,
  "twap_window_seconds": 30,
  "data": {
    "feed": "BTC/USD",
    "price": 66225.49,
    "bid": 66225.49,
    "ask": 66225.49,
    "timestamp": 1774672588,
    "is_twap": true,
    "twap_window_seconds": 30
  }
}
```

See [Event Format](https://docs.polynode.dev/crypto/event-format.md) for the full field reference.

## Combining with other streams

Crypto prices run on the same WebSocket connection as settlements, orderbook, and oracle streams. Send multiple subscribe messages:

```javascript JavaScript theme={null}
// Settlements + crypto prices on the same connection
ws.on("open", () => {
  ws.send(JSON.stringify({ action: "subscribe", type: "settlements" }));
  ws.send(JSON.stringify({ action: "subscribe", type: "chainlink" }));
});

ws.on("message", (data) => {
  const msg = JSON.parse(data);
  if (msg.type === "price_feed") {
    // crypto price tick
    console.log(`${msg.data.feed}: $${msg.data.price}`);
  } else if (msg.type === "settlement") {
    // settlement event
    console.log(`${msg.data.market_title}: ${msg.data.outcome}`);
  }
});
```

```python Python theme={null}
await ws.send(json.dumps({"action": "subscribe", "type": "settlements"}))
await ws.send(json.dumps({"action": "subscribe", "type": "chainlink"}))

async for message in ws:
    msg = json.loads(message)
    if msg.get("type") == "price_feed":
        d = msg["data"]
        print(f"Price: {d['feed']} ${d['price']}")
    elif msg.get("type") == "settlement":
        d = msg["data"]
        print(f"Settlement: {d['market_title']}: {d['outcome']}")
```

Use the `type` field (`"price_feed"` vs `"settlement"`) to route events.

## REST Endpoints

In addition to the WebSocket stream, crypto data is available via REST. See the [REST API reference](https://docs.polynode.dev/crypto/rest-api.md) for full details.

| Endpoint | Description |
| - | - |
| `GET /v1/crypto/markets` | All crypto prediction markets |
| `GET /v1/crypto/candles?symbol=BTC` | 5-min OHLC candles from Chainlink oracle |
| `GET /v1/crypto/ticks?symbol=BTC&from={unix_ms}&to={unix_ms}` | 1-second historical price ticks for chart backfill |
| `GET /v1/crypto/price?symbol=BTC&window={epoch}` | Open/close price for a market window |
| `GET /v1/crypto/active` | Currently active 5-minute markets for all 7 coins |
| `GET /v1/crypto/series` | Recurring crypto market series |

All endpoints require an API key via `?key=` or `x-api-key` header.

## Related guides

* [Chainlink Spot and TWAP Prices](https://docs.polynode.dev/crypto/twap.md)
* [Available Feeds](https://docs.polynode.dev/crypto/feeds.md)
* [Event Format](https://docs.polynode.dev/crypto/event-format.md)
* [Crypto REST API](https://docs.polynode.dev/crypto/rest-api.md)


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