# Subscribing & Unsubscribing

Once connected and authenticated to the sFOX WebSocket API you can subscribe to various feeds by using the subscribe or unsubscribe command.&#x20;

These commands should be JSON with the following properties:

<table><thead><tr><th width="162.1215494565709">Property</th><th width="118.24758455477465">Type</th><th>Command</th></tr></thead><tbody><tr><td><code>type</code></td><td>string</td><td>Command you are sending to the websocket (<code>subscribe</code> or <code>unsubscribe</code>)</td></tr><tr><td><code>feeds</code></td><td>string[]</td><td>List of the feeds that should be subscribed/unsubscribed to</td></tr></tbody></table>

{% tabs %}
{% tab title="NodeJS" %}

```javascript
const subscribeMsg = {
  type: 'subscribe',
  feeds: ['ticker.sfox.btcusd']
}
ws.send(JSON.stringify(subscribeMsg));

...

const unsubscribeMsg = {
  type: 'unsubscribe',
  feeds: ['ticker.sfox.btcusd']
}
ws.send(JSON.stringify(unsubscribeMsg))
```

{% endtab %}

{% tab title="Python" %}

```python
subscribe_msg = {
    "type": "subscribe",
    "feeds": ["ticker.sfox.btcusd"],
}

await ws.send(json.dumps(subscribe_msg))

...


unsubscribe_msg = {
    "type": "unsubscribe",
    "feeds": ["ticker.sfox.btcusd"],
}

await ws.send(json.dumps(unsubscribe_msg))
```

{% endtab %}
{% endtabs %}
