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

# Derivatives WebSocket

> Authentication, subscriptions, and real-time feeds for the Kraken Derivatives WebSocket API

## Endpoint

```text theme={null}
wss://futures.kraken.com/ws/v1
```

## Keeping the connection alive

Send a ping request at least every 60 seconds to keep the connection open. See the [sample implementation](https://github.com/CryptoFacilities/WebSocket-v1-Python/blob/master/cfWebSocketApiV1.py#L138) for reference.

## Snapshots and updates

Most feeds send a snapshot of the current state first, followed by real-time incremental updates.

## Authentication

Private feeds require a signed challenge. The process:

1. Connect to the WebSocket endpoint.
2. Send a request to obtain a challenge (using your `api_key`).
3. Sign the challenge with your `api_secret` (see [Sign challenge](#sign-challenge) below).
4. Include both `original_challenge` and `signed_challenge` in every subscribe/unsubscribe message for private feeds.

## Sign challenge

### Signing steps

Given a `challenge` string:

1. Hash the challenge with [SHA-256](https://en.wikipedia.org/wiki/SHA-2)
2. [Base64-decode](https://en.wikipedia.org/wiki/Base64) your `api_secret`
3. Hash the result of step 1 with the result of step 2 using [HMAC-SHA-512](https://en.wikipedia.org/wiki/Hash-based_message_authentication_code)
4. [Base64-encode](https://en.wikipedia.org/wiki/Base64) the result of step 3

The result of step 4 is the `signed_challenge`.

### Example

| Field              | Value                                                                                      |
| :----------------- | :----------------------------------------------------------------------------------------- |
| `challenge`        | `c100b894-1729-464d-ace1-52dbce11db42`                                                     |
| `api_secret`       | `7zxMEF5p/Z8l2p2U7Ghv6x14Af+Fx+92tPgUdVQ748FOIrEoT9bgT+bTRfXc5pz8na+hL/QdrCVG7bh9KpT0eMTm` |
| `signed_challenge` | `4JEpF3ix66GA2B+ooK128Ift4XQVtc137N9yeg4Kqsn9PI0Kpzbysl9M1IeCEdjg0zl00wkVqcsnG4bmnlMb3A==` |

The challenge is a [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) string.

## Subscribe request

```json theme={null}
{
  "event": "subscribe",
  "feed": "ticker",
  "product_ids": [
    "PI_XBTUSD",
    "FI_ETHUSD_210625"
  ]
}
```

For private feeds, include the challenge fields:

```json theme={null}
{
  "event": "subscribe",
  "feed": "open_orders",
  "api_key": "<your_api_key>",
  "original_challenge": "<challenge>",
  "signed_challenge": "<signed_challenge>"
}
```
