xo-orderbook-client-rs
use xo_orderbook_client::orderbook::{Client, Config};
use xo_orderbook_client::orderbook::types::request::PriceRequest;
use xo_orderbook_client::orderbook::types::Side;
use xo_orderbook_client::types::U256;
let client = Client::new("https://orderbooks.xo.market", Config::default())?;
let token_id = U256::from_str_radix(
"26516164265702901957933644848127860370782874751279270726689263951695181556943",
10,
)?;
let prices = client
.prices(&[
PriceRequest { token_id, side: Side::Buy },
PriceRequest { token_id, side: Side::Sell },
])
.await?;
curl --request POST \
--url https://orderbooks.xo.market/prices \
--header 'Content-Type: application/json' \
--data '
[
{
"token_id": "26516164265702901957933644848127860370782874751279270726689263951695181556943",
"side": "BUY"
},
{
"token_id": "26516164265702901957933644848127860370782874751279270726689263951695181556943",
"side": "SELL"
}
]
'import requests
url = "https://orderbooks.xo.market/prices"
payload = [
{
"token_id": "26516164265702901957933644848127860370782874751279270726689263951695181556943",
"side": "BUY"
},
{
"token_id": "26516164265702901957933644848127860370782874751279270726689263951695181556943",
"side": "SELL"
}
]
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify([
{
token_id: '26516164265702901957933644848127860370782874751279270726689263951695181556943',
side: 'BUY'
},
{
token_id: '26516164265702901957933644848127860370782874751279270726689263951695181556943',
side: 'SELL'
}
])
};
fetch('https://orderbooks.xo.market/prices', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://orderbooks.xo.market/prices",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'token_id' => '26516164265702901957933644848127860370782874751279270726689263951695181556943',
'side' => 'BUY'
],
[
'token_id' => '26516164265702901957933644848127860370782874751279270726689263951695181556943',
'side' => 'SELL'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://orderbooks.xo.market/prices"
payload := strings.NewReader("[\n {\n \"token_id\": \"26516164265702901957933644848127860370782874751279270726689263951695181556943\",\n \"side\": \"BUY\"\n },\n {\n \"token_id\": \"26516164265702901957933644848127860370782874751279270726689263951695181556943\",\n \"side\": \"SELL\"\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://orderbooks.xo.market/prices")
.header("Content-Type", "application/json")
.body("[\n {\n \"token_id\": \"26516164265702901957933644848127860370782874751279270726689263951695181556943\",\n \"side\": \"BUY\"\n },\n {\n \"token_id\": \"26516164265702901957933644848127860370782874751279270726689263951695181556943\",\n \"side\": \"SELL\"\n }\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://orderbooks.xo.market/prices")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "[\n {\n \"token_id\": \"26516164265702901957933644848127860370782874751279270726689263951695181556943\",\n \"side\": \"BUY\"\n },\n {\n \"token_id\": \"26516164265702901957933644848127860370782874751279270726689263951695181556943\",\n \"side\": \"SELL\"\n }\n]"
response = http.request(request)
puts response.read_body{
"26516164265702901957933644848127860370782874751279270726689263951695181556943": {
"BUY": "0.547",
"SELL": "0.553"
}
}Market Data
Get prices
Batch best-bid / best-ask. Pair with /midpoints to compute spreads locally without N+1 round-trips.
POST
/
prices
xo-orderbook-client-rs
use xo_orderbook_client::orderbook::{Client, Config};
use xo_orderbook_client::orderbook::types::request::PriceRequest;
use xo_orderbook_client::orderbook::types::Side;
use xo_orderbook_client::types::U256;
let client = Client::new("https://orderbooks.xo.market", Config::default())?;
let token_id = U256::from_str_radix(
"26516164265702901957933644848127860370782874751279270726689263951695181556943",
10,
)?;
let prices = client
.prices(&[
PriceRequest { token_id, side: Side::Buy },
PriceRequest { token_id, side: Side::Sell },
])
.await?;
curl --request POST \
--url https://orderbooks.xo.market/prices \
--header 'Content-Type: application/json' \
--data '
[
{
"token_id": "26516164265702901957933644848127860370782874751279270726689263951695181556943",
"side": "BUY"
},
{
"token_id": "26516164265702901957933644848127860370782874751279270726689263951695181556943",
"side": "SELL"
}
]
'import requests
url = "https://orderbooks.xo.market/prices"
payload = [
{
"token_id": "26516164265702901957933644848127860370782874751279270726689263951695181556943",
"side": "BUY"
},
{
"token_id": "26516164265702901957933644848127860370782874751279270726689263951695181556943",
"side": "SELL"
}
]
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify([
{
token_id: '26516164265702901957933644848127860370782874751279270726689263951695181556943',
side: 'BUY'
},
{
token_id: '26516164265702901957933644848127860370782874751279270726689263951695181556943',
side: 'SELL'
}
])
};
fetch('https://orderbooks.xo.market/prices', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://orderbooks.xo.market/prices",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'token_id' => '26516164265702901957933644848127860370782874751279270726689263951695181556943',
'side' => 'BUY'
],
[
'token_id' => '26516164265702901957933644848127860370782874751279270726689263951695181556943',
'side' => 'SELL'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://orderbooks.xo.market/prices"
payload := strings.NewReader("[\n {\n \"token_id\": \"26516164265702901957933644848127860370782874751279270726689263951695181556943\",\n \"side\": \"BUY\"\n },\n {\n \"token_id\": \"26516164265702901957933644848127860370782874751279270726689263951695181556943\",\n \"side\": \"SELL\"\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://orderbooks.xo.market/prices")
.header("Content-Type", "application/json")
.body("[\n {\n \"token_id\": \"26516164265702901957933644848127860370782874751279270726689263951695181556943\",\n \"side\": \"BUY\"\n },\n {\n \"token_id\": \"26516164265702901957933644848127860370782874751279270726689263951695181556943\",\n \"side\": \"SELL\"\n }\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://orderbooks.xo.market/prices")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "[\n {\n \"token_id\": \"26516164265702901957933644848127860370782874751279270726689263951695181556943\",\n \"side\": \"BUY\"\n },\n {\n \"token_id\": \"26516164265702901957933644848127860370782874751279270726689263951695181556943\",\n \"side\": \"SELL\"\n }\n]"
response = http.request(request)
puts response.read_body{
"26516164265702901957933644848127860370782874751279270726689263951695181556943": {
"BUY": "0.547",
"SELL": "0.553"
}
}