Websocket General Info
Basic
- Base Url:
- Testnet:
wss://stream.base-sepolia.jojo.exchange/v1
- Mainnet:
- BASE
wss://stream.base-mainnet.jojo.exchange/v1
- BASE
- Testnet:
- Streams can be accessed either in a raw stream or a combined stream
- Raw streams are accessed at
/single/<streamName>
- Example:
wss://stream.base-sepolia.jojo.exchange/v1/single/btcusdc@orderbook
- Example:
- Combined streams are accessed at
/multiple?streams=<streamName1>/<streamName2>/<streamName3>
- Example:
wss://stream.base-sepolia.jojo.exchange/v1/multiple?streams=btcusdc@orderbook
- Example:
- Combined stream events are wrapped as follows:
{ "stream": "<streamName>", "data": "<rawPayload>" }
- All stream names should be in lowercase.
- Each connection is valid for a maximum of 12 hours. You should expect the connection to be disconnected after 12 hours.
- The WebSocket server sends a "ping frame" every 5 seconds. If the server does not receive a "pong frame" back from the connection within 15 seconds, the connection will be terminated. However, unsolicited "pong frames" are allowed. The WebSocket server supports both WebSocket ping/pong frames and text "ping"/"pong" messages, which operate in the same manner.
- Repeated disconnections from the same IP address may result in a ban.
- When establishing a connection, you can pass a URL parameter named
zip
. If this parameter is not an empty string, all data returned by the server will be compressed using zlib, with the exception of the server's text "ping" message which will not be compressed.
More about combined streams
- In addition to subscribing to steam through query parameters, connections support live Subscribing/Unsubscribing to streams. Examples can be seen below.
- WebSocket connections have a limit of 10 incoming messages per second. A connection that goes beyond the limit will be disconnected.
- A single connection can listen to a maximum of 50 streams.
- The id used in the JSON payloads is an unsigned non-zero INT used as an identifier to uniquely identify the messages going back and forth.
- The maximum request message size cannot be larger than 1KB.
Subscribe to a stream
// Request
{
"id": 1,
"method": "SUBSCRIBE",
"params": [
"btcusdc@orderbook"
]
}
// Response
{
"result": null,
"id": 1
}
Unsubscribe to a stream
// Request
{
"id": 2,
"method": "UNSUBSCRIBE",
"params": [
"btcusdc@orderbook"
]
}
// Response
{
"result": null,
"id": 2
}
Listing Subscriptions
// Request
{
"id": 3,
"method": "LIST_SUBSCRIPTIONS"
}
// Response
{
"result": ["btcusdc@orderbook"],
"id": 3
}
Error Messages
Code 0:
Parameter id had to be provided or the value provided in the id parameter is an unsupported type
{"code": 0, "msg": "Invalid request: request ID must be an unsigned non-zero integer"}
Code 1:
A Possible typo in the provided method or provided method was neither of the expected values
{"code": 1, "msg": "Invalid method. Expected one of SUBSCRIBE, UNSUBSCRIBE, LIST_SUBSCRIPTIONS"}
Code 2:
Invalid parameters provided in the data
{"code": 2, "msg": "Invalid params"}
Code 3:
JSON data sent has incorrect syntax
{"code": 3, "msg": "Invalid JSON"}
Code 4:
The maximum number of subscribed steams has been reached
{"code": 4, "msg": "The maximum number of subscribed steams has been reached"}
Code 5:
No such stream. The connection will be closed