xo-orderbook-client-rs
use xo_orderbook_client::orderbook::{Client, Config};
use xo_orderbook_client::orderbook::types::request::LastTradePriceRequest;
use xo_orderbook_client::types::U256;
let client = Client::new("https://orderbooks.xo.market", Config::default())?;
let yes = U256::from_str_radix("26516164265702901957933644848127860370782874751279270726689263951695181556943", 10)?;
let no = U256::from_str_radix("13730057904096984444199595880113152612639388204530324084054099203558669491245", 10)?;
let resp = client
.last_trades_prices(&[
LastTradePriceRequest { token_id: yes },
LastTradePriceRequest { token_id: no },
])
.await?;
// Tokens with no trade data are silently omitted from `resp`.
curl --request GET \
--url https://orderbooks.xo.market/last-trades-prices \
--header 'Content-Type: application/json' \
--data '
[
{
"token_id": "26516164265702901957933644848127860370782874751279270726689263951695181556943"
},
{
"token_id": "13730057904096984444199595880113152612639388204530324084054099203558669491245"
}
]
'import requests
url = "https://orderbooks.xo.market/last-trades-prices"
payload = [{ "token_id": "26516164265702901957933644848127860370782874751279270726689263951695181556943" }, { "token_id": "13730057904096984444199595880113152612639388204530324084054099203558669491245" }]
headers = {"Content-Type": "application/json"}
response = requests.get(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify([
{
token_id: '26516164265702901957933644848127860370782874751279270726689263951695181556943'
},
{
token_id: '13730057904096984444199595880113152612639388204530324084054099203558669491245'
}
])
};
fetch('https://orderbooks.xo.market/last-trades-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/last-trades-prices",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => json_encode([
[
'token_id' => '26516164265702901957933644848127860370782874751279270726689263951695181556943'
],
[
'token_id' => '13730057904096984444199595880113152612639388204530324084054099203558669491245'
]
]),
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/last-trades-prices"
payload := strings.NewReader("[\n {\n \"token_id\": \"26516164265702901957933644848127860370782874751279270726689263951695181556943\"\n },\n {\n \"token_id\": \"13730057904096984444199595880113152612639388204530324084054099203558669491245\"\n }\n]")
req, _ := http.NewRequest("GET", 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.get("https://orderbooks.xo.market/last-trades-prices")
.header("Content-Type", "application/json")
.body("[\n {\n \"token_id\": \"26516164265702901957933644848127860370782874751279270726689263951695181556943\"\n },\n {\n \"token_id\": \"13730057904096984444199595880113152612639388204530324084054099203558669491245\"\n }\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://orderbooks.xo.market/last-trades-prices")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request.body = "[\n {\n \"token_id\": \"26516164265702901957933644848127860370782874751279270726689263951695181556943\"\n },\n {\n \"token_id\": \"13730057904096984444199595880113152612639388204530324084054099203558669491245\"\n }\n]"
response = http.request(request)
puts response.read_body[
{
"token_id": "26516164265702901957933644848127860370782874751279270726689263951695181556943",
"price": "0.553",
"side": "BUY"
},
{
"token_id": "13730057904096984444199595880113152612639388204530324084054099203558669491245",
"price": "0.447",
"side": "SELL"
}
]Market Data
Get last trade prices
Batch last trade prices.
GET
/
last-trades-prices
xo-orderbook-client-rs
use xo_orderbook_client::orderbook::{Client, Config};
use xo_orderbook_client::orderbook::types::request::LastTradePriceRequest;
use xo_orderbook_client::types::U256;
let client = Client::new("https://orderbooks.xo.market", Config::default())?;
let yes = U256::from_str_radix("26516164265702901957933644848127860370782874751279270726689263951695181556943", 10)?;
let no = U256::from_str_radix("13730057904096984444199595880113152612639388204530324084054099203558669491245", 10)?;
let resp = client
.last_trades_prices(&[
LastTradePriceRequest { token_id: yes },
LastTradePriceRequest { token_id: no },
])
.await?;
// Tokens with no trade data are silently omitted from `resp`.
curl --request GET \
--url https://orderbooks.xo.market/last-trades-prices \
--header 'Content-Type: application/json' \
--data '
[
{
"token_id": "26516164265702901957933644848127860370782874751279270726689263951695181556943"
},
{
"token_id": "13730057904096984444199595880113152612639388204530324084054099203558669491245"
}
]
'import requests
url = "https://orderbooks.xo.market/last-trades-prices"
payload = [{ "token_id": "26516164265702901957933644848127860370782874751279270726689263951695181556943" }, { "token_id": "13730057904096984444199595880113152612639388204530324084054099203558669491245" }]
headers = {"Content-Type": "application/json"}
response = requests.get(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify([
{
token_id: '26516164265702901957933644848127860370782874751279270726689263951695181556943'
},
{
token_id: '13730057904096984444199595880113152612639388204530324084054099203558669491245'
}
])
};
fetch('https://orderbooks.xo.market/last-trades-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/last-trades-prices",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => json_encode([
[
'token_id' => '26516164265702901957933644848127860370782874751279270726689263951695181556943'
],
[
'token_id' => '13730057904096984444199595880113152612639388204530324084054099203558669491245'
]
]),
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/last-trades-prices"
payload := strings.NewReader("[\n {\n \"token_id\": \"26516164265702901957933644848127860370782874751279270726689263951695181556943\"\n },\n {\n \"token_id\": \"13730057904096984444199595880113152612639388204530324084054099203558669491245\"\n }\n]")
req, _ := http.NewRequest("GET", 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.get("https://orderbooks.xo.market/last-trades-prices")
.header("Content-Type", "application/json")
.body("[\n {\n \"token_id\": \"26516164265702901957933644848127860370782874751279270726689263951695181556943\"\n },\n {\n \"token_id\": \"13730057904096984444199595880113152612639388204530324084054099203558669491245\"\n }\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://orderbooks.xo.market/last-trades-prices")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request.body = "[\n {\n \"token_id\": \"26516164265702901957933644848127860370782874751279270726689263951695181556943\"\n },\n {\n \"token_id\": \"13730057904096984444199595880113152612639388204530324084054099203558669491245\"\n }\n]"
response = http.request(request)
puts response.read_body[
{
"token_id": "26516164265702901957933644848127860370782874751279270726689263951695181556943",
"price": "0.553",
"side": "BUY"
},
{
"token_id": "13730057904096984444199595880113152612639388204530324084054099203558669491245",
"price": "0.447",
"side": "SELL"
}
]