# WebSocket Integration

This guide walks you through how to create and deploy a **custom WebSocket server** that works seamlessly with Stellar. This feature allows **external monitoring servers** to push real time product data directly into the bot, giving Stellar users faster and more customized alerts.

It’s perfect for **cook groups, monitor providers or developers** who want to power Stellar’s WebSocket tab with their own monitoring.

<figure><img src="https://1122101074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQL0BOlyqRRf7zyNKSf%2Fuploads%2FiXaqF7r43hwjR9xlZgNc%2Fwebsockets.PNG?alt=media&#x26;token=b8a7bce6-680b-4631-b2bf-e021f2bc6ba3" alt=""><figcaption></figcaption></figure>

***

### What is Stellar’s WebSocket Feature?

Stellar users can now connect to **external WebSocket servers** via a dedicated field in the Settings tab. These servers act just like Stellar’s in house server side monitor, providing fast and reliable product pings for supported modules.

This gives you the power to:

* Run your own monitors and deliver custom product pings to users
* Monetize or enhance your group offerings with Stellar compatible support
* Push lightning fast restock info from your own backends into Stellar tasks

***

### How Does It Work?

When you add your WebSocket server in your bot settings, Stellar connects to your endpoint (`ws://` or `wss://`) and begins listening for product restock pings in real time.

Your server should:

* Accept connections from authenticated Stellar users
* Broadcast product pings to all connected users in **Stellar’s accepted format**
* Optionally restrict or track key usage (for private servers)

<figure><img src="https://1122101074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQL0BOlyqRRf7zyNKSf%2Fuploads%2FT58bmQzTGI2gCt0MuvOU%2Fcontainer_virtual-machine_530x330.jpg?alt=media&#x26;token=6d7b24dc-bc2b-4cfd-b0db-0bb74878bebc" alt=""><figcaption></figcaption></figure>

***

### How Do I Build a Compatible WebSocket Server?

You can use **any backend language or framework** as long as it:

* Accepts WebSocket traffic (port 80 for `ws://`, or 443 for `wss://` via reverse proxy like NGINX)
* Sends properly formatted **stringified JSON payloads**
* Authenticates users by API key (via query string)

We recommend building with **Node.js**, **Python**, **Go**, or **Rust** for ease of development and scale but any language that supports WebSocket libraries will work.

***

### Websocket Format

#### Amazon Format

**Required for Amazon connections:**

* `region`, `sku`, and `offerId` are **required**
* `productImage` must be a **valid URL**
* `productPrice` must be a **string**
* Supported Regions:\
  `['USA', 'CA', 'UK', 'NL', 'FR', 'IT', 'DE', 'JP', 'ES', 'BE', 'PL', 'AU']`

```
{
  "site": "amazon",
  "region": "USA",
  "sku": "B09MQ5L5N9",
  "offerId": "OID",
  "details": {
    "productTitle": "Amazon Test",
    "productImage": "https://www.image.com/",
    "productPrice": "199.99"
  }
}
```

#### All Other Sites

* `sku` is always **required**
* `offerId` is only used for **Walmart USA/CA**
* `productImage` must be a **valid URL**
* `productPrice` must be a **string**

```
{
  "site": "exactly like in task creator",
  "sku": "SKU required",
  "offerId": "only Walmart USA/CA",
  "details": {
    "productTitle": "Example Product",
    "productImage": "https://www.image.com/",
    "productPrice": "199.99"
  }
}
```

{% hint style="warning" %}
Due to the number of supported sites, not all have been individually tested. We strongly recommend testing your WebSocket with an in stock item and if detection doesn’t work, open a ticket and we'll tag the dev team.
{% endhint %}
