# WebSocket Quickstart

> Open an authenticated Solana WebSocket and receive live slot updates.

Canonical: https://nolimitnodes.com/docs/quickstarts/websocket

Use WebSocket subscriptions for account changes, logs, signatures, slots, blocks, and votes.

## Connect from a terminal

Install `wscat`, then pass your API key during the HTTP upgrade.

```bash
npm install --global wscat

wscat -c wss://ws.nln.clr3.org -H "x-api-key: $NLN_API_KEY"
```

Send a slot subscription after the connection opens.

```json
{
  "jsonrpc": "2.0",
  "id": "slots",
  "method": "slotSubscribe"
}
```

The first response contains a numeric subscription ID. Later messages use `slotNotification`.

```json
{
  "jsonrpc": "2.0",
  "method": "slotNotification",
  "params": {
    "result": {
      "parent": 357954000,
      "root": 357953968,
      "slot": 357954001
    },
    "subscription": 42
  }
}
```

## Stop the subscription

Pass the subscription ID to `slotUnsubscribe`.

```json
{
  "jsonrpc": "2.0",
  "id": "stop-slots",
  "method": "slotUnsubscribe",
  "params": [42]
}
```

## Browser clients

The browser `WebSocket` constructor has no option for custom upgrade headers. Do not place your API key in browser code.

Use one of these paths:

- Open the connection from your backend.
- Relay selected events to your browser.
- Keep the NoLimitNodes key in server-side secrets.

  ### [WebSocket authentication](/docs/guides/websocket-authentication)

Pick a safe connection pattern for Node.js and browser apps.

  ### [Reconnect safely](/docs/guides/websocket-reconnect)

Restore subscriptions after a dropped connection.
