Orderbook Streaming
stream::orderbook::enable
Using this method, you can enable the orderbook stream for a given pair.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| base | string | ✓ | Base currency of a pair |
| client_id | integer | ✓ | This ID can be used to access data (e.g. via http://localhost:7783/event-stream?id=1) |
| rel | string | ✓ | Related currency, also known as the "quote currency" |
Response Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| streamer_id | string | – | An identifier for the data stream. This can be used later to disable streaming for the event with stream::disable. |
📌 Examples
stream::orderbook::enable {
"userpass": "RPC_UserP@SSW0RD",
"method": "stream::orderbook::enable",
"mmrpc": "2.0",
"params": {
"client_id": 1,
"base": "DOC",
"rel": "MARTY"
}
} curl --url "http://127.0.0.1:7783" --data '{
"userpass": "RPC_UserP@SSW0RD",
"method": "stream::orderbook::enable",
"mmrpc": "2.0",
"params": {
"client_id": 1,
"base": "DOC",
"rel": "MARTY"
}
}' import requests
import json
url = "http://127.0.0.1:7783"
payload = {
"userpass": "RPC_UserP@SSW0RD",
"method": "stream::orderbook::enable",
"mmrpc": "2.0",
"params": {
"client_id": 1,
"base": "DOC",
"rel": "MARTY"
}
}
response = requests.post(url, json=payload)
print(json.dumps(response.json(), indent=2)) const payload = {
"userpass": "RPC_UserP@SSW0RD",
"method": "stream::orderbook::enable",
"mmrpc": "2.0",
"params": {
"client_id": 1,
"base": "DOC",
"rel": "MARTY"
}
};
const response = await fetch("http://127.0.0.1:7783", {
method: "POST",
body: JSON.stringify(payload),
});
console.log(await response.json()); <?php
$payload = <<<'JSON'
{
"userpass": "RPC_UserP@SSW0RD",
"method": "stream::orderbook::enable",
"mmrpc": "2.0",
"params": {
"client_id": 1,
"base": "DOC",
"rel": "MARTY"
}
}
JSON;
$ch = curl_init("http://127.0.0.1:7783");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response = curl_exec($ch);
curl_close($ch);
echo $response; package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
payload := []byte(`{"userpass":"RPC_UserP@SSW0RD","method":"stream::orderbook::enable","mmrpc":"2.0","params":{"client_id":1,"base":"DOC","rel":"MARTY"}}`)
resp, err := http.Post("http://127.0.0.1:7783", "application/json", bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
} require 'net/http'
require 'json'
require 'uri'
uri = URI("http://127.0.0.1:7783")
payload = {
"userpass": "RPC_UserP@SSW0RD",
"method": "stream::orderbook::enable",
"mmrpc": "2.0",
"params": {
"client_id": 1,
"base": "DOC",
"rel": "MARTY"
}
}
response = Net::HTTP.post(uri, payload.to_json, 'Content-Type' => 'application/json')
puts JSON.pretty_generate(JSON.parse(response.body)) Show Enable Orderbook Streaming Response
{
"mmrpc": "2.0",
"result": {
"streamer_id": "ORDERBOOK_UPDATE/orbk/DOC:MARTY"
},
"id": null
} Here is an example of the stream data you should be able to see in http://localhost:7783/event-stream?id=1 for each orderbook updated event:
data: {"_type":"ORDERBOOK_UPDATE/orbk/KMD:MATIC","message":{"order_type":"NewOrUpdatedItem","order_data":{"pubkey":"026da2fc632afabbb1b86d04a9a012db25eca74db38ba2eccd88552f27f4c0b245","base":"MATIC","rel":"KMD","price":[[1,[4249903049,3]],[1,[1410065408,2]]],"max_volume":[[1,[1477927621,23427]],[1,[1783793664,116]]],"min_volume":[[1,[1223297773,7148]],[1,[552894464,46566]]],"uuid":"b18bb3ab-8476-4a06-9cf6-9744e1bf6442","created_at":1746432644}}}
Error Types
| Parameter | Type | Required | Description |
|---|---|---|---|
| UnknownClient | string | – | No client has an open connection using this client_id |
| ClientAlreadyListening | string | – | The requested events are already being sent to the client_id |
Show Error Responses
Error Response (Unknown Client)
No client has an open connection using this client_id.
{
"mmrpc": "2.0",
"error": "UnknownClient",
"error_path": "orderbook",
"error_trace": "orderbook:36]",
"error_type": "EnableError",
"error_data": "UnknownClient",
"id": null
}Error (Client Already Listening)
The requested events are already being sent to the client_id.
{
"mmrpc": "2.0",
"error": "ClientAlreadyListening",
"error_path": "orderbook",
"error_trace": "orderbook:36]",
"error_type": "EnableError",
"error_data": "ClientAlreadyListening",
"id": null
} Here is an example of the stream data you should be able to see in http://localhost:7783/event-stream?id=1 for each orderbook updated event:
data: {"_type":"ORDERBOOK_UPDATE/orbk/KMD:MATIC","message":{"order_type":"NewOrUpdatedItem","order_data":{"pubkey":"026da2fc632afabbb1b86d04a9a012db25eca74db38ba2eccd88552f27f4c0b245","base":"MATIC","rel":"KMD","price":[[1,[4249903049,3]],[1,[1410065408,2]]],"max_volume":[[1,[1477927621,23427]],[1,[1783793664,116]]],"min_volume":[[1,[1223297773,7148]],[1,[552894464,46566]]],"uuid":"b18bb3ab-8476-4a06-9cf6-9744e1bf6442","created_at":1746432644}}}