Developers
SDKs & Examples
Copy-paste ready examples for REST and WebSocket access. Replace the base URL with the value from the Get Started page and adjust paths as needed.
Browser REST GET /api/v1/quotes/:symbol
Minimal fetch-based client for reading a single quote from the Market Data
API.
const BASE_URL = process.env.SIDIORA_MARKET_DATA_URL; // see Get Started page
async function getQuote(symbol) {
const url = new URL('/api/v1/quotes/' + encodeURIComponent(symbol), BASE_URL);
const res = await fetch(url.toString());
if (!res.ok) {
throw new Error('Request failed with ' + res.status);
}
return res.json();
}
getQuote("btcusd").then(console.log).catch(console.error);
React hook WS /ws/quotes
Example React hook for subscribing to live quotes over WebSocket. This is adapted from the Market Data API documentation.
import { useEffect, useState } from "react";
const WS_URL = process.env.SIDIORA_MARKET_DATA_WS_URL; // see Get Started
type Quote = {
symbol: string;
bid: number;
ask: number;
last: number;
change24h: number;
changePercent24h: number;
timestamp: string;
};
export function useMarketData(symbols: string[]) {
const [quotes, setQuotes] = useState<Record<string, Quote>>({});
const [connected, setConnected] = useState(false);
useEffect(() => {
if (!symbols.length) return;
const ws = new WebSocket(WS_URL!);
ws.onopen = () => {
setConnected(true);
ws.send(
JSON.stringify({
action: "subscribe",
symbols,
}),
);
};
ws.onmessage = (event) => {
const quote = JSON.parse(event.data) as Quote;
setQuotes((prev) => ({
...prev,
[quote.symbol]: quote,
}));
};
ws.onclose = () => setConnected(false);
return () => {
ws.close();
};
}, [symbols.join(",")]);
return { quotes, connected };
}
Node.js fetch GET /api/ecosystem/market
Example Node.js snippet for listing ecosystem markets using a base URL from configuration.
import fetch from "node-fetch";
const BASE_URL = process.env.SIDIORA_PLATFORM_URL; // see Get Started
async function listEcosystemMarkets() {
const url = new URL("/api/ecosystem/market", BASE_URL);
const res = await fetch(url.toString());
if (!res.ok) {
throw new Error('Request failed with ' + res.status);
}
return res.json();
}
listEcosystemMarkets().then(console.log).catch(console.error);