sFOX API
Sign In
Open Account
Search…
Introduction
REST API
REST Endpoints
Authentication
Account Management
Custody
Orders
Algorithms & Routing Types
Market Data
WebSocket API
WebSocket API Introduction
Connecting
Authentication
Subscribing & Unsubscribing
Message Format
Market Data
Orders & Account Data
Enterprise
FIX API
FIX
Errors
Error Codes
Powered By
GitBook
Subscribing & Unsubscribing
Subscribing or unsubscribing to WebSocket feeds
Once connected to the WebSocket API you can subscribe to various feeds using the
subscribe
or
unsubscribe
command.
These commands should be JSON with the following properties:
Property
Type
Description
type
string
Command you are sending to the websocket (
subscribe
or
unsubscribe
)
feeds
string[]
List of the feeds that should be subscribed/unsubscribed to
NodeJS
Python
1
const
subscribeMsg
=
{
2
type
:
'subscribe'
,
3
feeds
:
[
'ticker.sfox.btcusd'
]
4
}
5
ws
.
send
(
JSON
.
stringify
(
subscribeMsg
));
6
7
...
8
9
const
unsubscribeMsg
=
{
10
type
:
'unsubscribe'
,
11
feeds
:
[
'ticker.sfox.btcusd'
]
12
}
13
ws
.
send
(
JSON
.
stringify
(
unsubscribeMsg
))
Copied!
1
subscribe_msg
=
{
2
"type"
:
"subscribe"
,
3
"feeds"
:
[
"ticker.sfox.btcusd"
],
4
}
5
6
await
ws
.
send
(
json
.
dumps
(
subscribe_msg
))
7
8
...
9
10
11
unsubscribe_msg
=
{
12
"type"
:
"unsubscribe"
,
13
"feeds"
:
[
"ticker.sfox.btcusd"
],
14
}
15
16
await
ws
.
send
(
json
.
dumps
(
unsubscribe_msg
))
Copied!
WebSocket API - Previous
Authentication
Next - WebSocket API
Message Format
Last modified
1mo ago
Copy link