# Real-Time API (WebSockets)

#### [wss://rt.criptan.com](wss://rt.criptan.com)

Criptan's Interactive API empowers you to establish a dynamic, two-way communication session between your client and our server. With this API, you can effortlessly send messages to the server and receive event-driven responses in real-time, eliminating the need for continuous polling.

## Authentication

To ensure secure access, authentication is achieved by sending the authorization token in the `authorization` query string parameter.

## Supported messages

### Subscribe/Unsubscribe to a topic

In order to start receiving data in real-time from a specific topic.

Topics available are:

<table><thead><tr><th width="272">Topic</th><th>Description</th></tr></thead><tbody><tr><td>GENERAL</td><td>For general updates. Automatically subscribed when the connection is stablished.</td></tr><tr><td>OHLCV</td><td>Aggregated form of market data standing for Open, High, Low, Close and Volume. For all Criptan assets and for intervals of 1m, 5m, 15min, 1h, 4h, 1d, 1w, 2w.</td></tr><tr><td>TICKERS</td><td>A ticker is a report of the current market prices for an individual currency pair.</td></tr></tbody></table>

#### CLIENT MESSAGES

#### subscribe

```
{"action":"subscribe","topic": "OHLCV"}
```

#### unsubscribe

```
{"action":"unsubscribe","topic": "OHLCV"}
```

**SERVER MESSAGES**

**subscriptionStatus**

```
{"action":"subscriptionStatus","topic":"OHLCV","status":"subscribed"}
```

```
{"action":"subscriptionStatus","topic":"OHLCV","status":"unsubscribed"}
```

## Errors

We've implemented a robust error handling system to ensure smooth interactions. Here are the possible error messages:

**ZodError:**&#x20;

<pre><code>{
<strong>    "name": "ZodError",
</strong>    "issues": [
        {
            "received": "OHLCCV",
            "code": "invalid_enum_value",
            "options": [
                "GENERAL",
                "OHLCV"
            ],
            "path": [
                "body",
                "topic"
            ],
            "message": "Invalid enum value. Expected 'GENERAL' | 'OHLCV', received 'OHLCCV'"
        }
    ],
}
</code></pre>

**ResourceNotFound**

```
{"message":"Resource not found","code":"resource_not_found"}
```

**InternalError**

```
{"message":"Internal error","code":"internal_error"}
```

The Interactive API offers a seamless and secure way to engage in real-time communication with Criptan's servers. Whether you're subscribing to topics or managing errors, our API is designed to provide a smooth and efficient experience.
