> For the complete documentation index, see [llms.txt](https://docs.synthdata.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.synthdata.co/websocket-api.md).

# Websocket API

All insights are available in websocket. They are refreshed every 15 or 35 seconds depending on the asset. Websocket server will push the new version at each refresh. An API credit is then consume at each server push.

### Base URL

{% code title="Base URL" %}

```
wss://api.synthdata.co/ws
```

{% endcode %}

### Authentication

{% hint style="info" %}
All requests require an API key in the query parameters:

```
apikey=YOUR_API_KEY
```

{% endhint %}

### Example

```html
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Synth WebSocket API</title>
  </head>

  <body>
    <p id="output"></p>

    <script>
      const apiKey = prompt("Enter your API key") || "";
      const uri = `wss://api.synthdata.co/ws/insights/liquidation?asset=SOL&apikey=${encodeURIComponent(apiKey)}`;

      ws = new WebSocket(uri);

      ws.onopen = function () {
        console.log("Connected");
      };

      ws.onmessage = function (evt) {
        var out = document.getElementById("output");
        out.innerHTML += evt.data + "<br>";
      };

      ws.onerror = function (err) {
        console.error("WebSocket error:", err);
      };

      ws.onclose = function (evt) {
        console.log("WebSocket closed:", evt.code, evt.reason);
      };
    </script>
  </body>
</html>

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.synthdata.co/websocket-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
