# Quickstart

To use our API, you must have valid credentials. Please visit our [website](https://stalkapi.com) to create an account and obtain your API Key.

{% hint style="info" %}
To access our API, a paid subscription is required as we do not provide free accounts or trials
{% endhint %}

***

### Websocket

Endpoint: `wss://data.stalkapi.com/ws?apiKey=YOUR_API_KEY`

```javascript
const WebSocket = require("ws");

const ws = new WebSocket("wss://data.stalkapi.com/ws?apiKey=YOUR_API_KEY");

// Subscribing to a stream
ws.send(
  JSON.stringify({
    type: "subscribe",
    payload: {
      stream: "kol-feed",
      parameters: {...} // some endpoints accept additional parameters 
    },
  })
);

```

***

### API

Endpoint: `https://data.stalkapi.com`

```javascript
async function fetchStalkAPI() {
  const API_KEY = 'YOUR_API_KEY';
  const API_URL = 'https://data.stalkapi.com';

  try {
    const response = await fetch(API_URL, {
      method: 'GET',
      headers: {
        'X-API-Key': API_KEY,
        'Content-Type': 'application/json'
      }
    });

    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`);
    }

    const data = await response.json();
    return data;
  } catch (error) {
    console.error('Error fetching from StalkAPI:', error);
    throw error;
  }
}

const result = fetchStalkAPI();
console.log(result);
```
