> 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>

```
