xo-orderbook-client-rs
use alloy::signers::local::LocalSigner;
use xo_orderbook_client::orderbook::{Client, Config};
let signer = LocalSigner::from_bytes(&std::env::var("XO_PRIVATE_KEY")?.parse()?)?;
let client = Client::new("https://orderbooks.xo.market", Config::default())?;
let creds = client.derive_api_key(&signer).await?;
// Returns the existing (oldest) key. 404 if no key exists yet.
curl --request GET \
--url https://orderbooks.xo.market/auth/derive-api-key \
--header 'XO_ADDRESS: <api-key>'import requests
url = "https://orderbooks.xo.market/auth/derive-api-key"
headers = {"XO_ADDRESS": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {XO_ADDRESS: '<api-key>'}};
fetch('https://orderbooks.xo.market/auth/derive-api-key', 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/auth/derive-api-key",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"XO_ADDRESS: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://orderbooks.xo.market/auth/derive-api-key"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("XO_ADDRESS", "<api-key>")
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/auth/derive-api-key")
.header("XO_ADDRESS", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://orderbooks.xo.market/auth/derive-api-key")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["XO_ADDRESS"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"apiKey": "7a3f9c1d-8b2e-4a5c-9d1e-2f3a4b5c6d7e",
"secret": "dGhpcy1pcy1hbi1leGFtcGxlLWhtYWMtc2VjcmV0LWtleS1iYXNlNjQ=",
"passphrase": "9f3a2b1c4d5e6f708192a3b4c5d6e7f8"
}{
"error": "no API key found for address 0xCAFE000000000000000000000000000000000A11"
}Authentication
Derive API key
Deterministically derive the caller’s existing key — returns
the oldest key in insertion order so repeat callers see a
stable result. Never mints; use POST /auth/api-key for that.
GET
/
auth
/
derive-api-key
xo-orderbook-client-rs
use alloy::signers::local::LocalSigner;
use xo_orderbook_client::orderbook::{Client, Config};
let signer = LocalSigner::from_bytes(&std::env::var("XO_PRIVATE_KEY")?.parse()?)?;
let client = Client::new("https://orderbooks.xo.market", Config::default())?;
let creds = client.derive_api_key(&signer).await?;
// Returns the existing (oldest) key. 404 if no key exists yet.
curl --request GET \
--url https://orderbooks.xo.market/auth/derive-api-key \
--header 'XO_ADDRESS: <api-key>'import requests
url = "https://orderbooks.xo.market/auth/derive-api-key"
headers = {"XO_ADDRESS": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {XO_ADDRESS: '<api-key>'}};
fetch('https://orderbooks.xo.market/auth/derive-api-key', 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/auth/derive-api-key",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"XO_ADDRESS: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://orderbooks.xo.market/auth/derive-api-key"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("XO_ADDRESS", "<api-key>")
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/auth/derive-api-key")
.header("XO_ADDRESS", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://orderbooks.xo.market/auth/derive-api-key")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["XO_ADDRESS"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"apiKey": "7a3f9c1d-8b2e-4a5c-9d1e-2f3a4b5c6d7e",
"secret": "dGhpcy1pcy1hbi1leGFtcGxlLWhtYWMtc2VjcmV0LWtleS1iYXNlNjQ=",
"passphrase": "9f3a2b1c4d5e6f708192a3b4c5d6e7f8"
}{
"error": "no API key found for address 0xCAFE000000000000000000000000000000000A11"
}Authorizations
L1 ClobAuth EIP-712 wallet signature. See Authentication.
Response
OK. Returns the caller's existing (oldest) key, NOT a fresh one.
camelCase wire keys per CLOB SDK contract. The triplet is the full credential — the secret/passphrase are never returned again. Store them on receipt.
UUIDv4 — sent as POLY_API_KEY header on every L2 HMAC request.
Base64-encoded HMAC secret. Used to sign the request canonical string; never sent on the wire after creation.
Sent as POLY_PASSPHRASE header. Distinct from the secret —
both must match for the request to authenticate.