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

# Coinbase WebSockets

> Real-time Coinbase Exchange market data

**Upstream:** `wss://ws-feed.exchange.coinbase.com`

## Connect

```bash theme={null}
wscat -c "wss://gateway.graylayer.tech/ws/coinbase?api_key=your_key"
```

Send a `subscribe` message within 5 seconds of connecting:

```json theme={null}
{
  "type": "subscribe",
  "product_ids": ["BTC-USD", "ETH-USD"],
  "channels": ["ticker", "level2", "heartbeat"]
}
```

## Channels

| Channel     | Description                              |
| ----------- | ---------------------------------------- |
| `ticker`    | Real-time price updates                  |
| `level2`    | Full order book updates                  |
| `heartbeat` | Heartbeat messages to detect disconnects |
| `matches`   | Matched orders (trades)                  |
| `status`    | Product status changes                   |

## Unsubscribe

```json theme={null}
{
  "type": "unsubscribe",
  "product_ids": ["BTC-USD"],
  "channels": ["ticker"]
}
```
