curl --request POST \
--url https://rpc.testnet.tempo.xyz/ \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"method": "dex_getOrderbooks",
"params": [
{
"limit": 10
}
],
"id": 1
}
'{
"jsonrpc": "<string>",
"id": 123,
"result": {
"nextCursor": "<string>",
"orderbooks": [
{}
]
}
}curl --request POST \
--url https://rpc.testnet.tempo.xyz/ \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"method": "dex_getOrderbooks",
"params": [
{
"limit": 10
}
],
"id": 1
}
'{
"jsonrpc": "<string>",
"id": 123,
"result": {
"nextCursor": "<string>",
"orderbooks": [
{}
]
}
}params — pagination object:
limit — (optional) maximum number of orderbooks to return (default: 10, max: 100)cursor — (optional) cursor for pagination from previous responsefilters — (optional) filter object:
baseToken — filter by base token addressquoteToken — filter by quote token addressbestAskTick — filter by best ask tick rangebestBidTick — filter by best bid tick rangespread — filter by spread rangeresult — response object:
nextCursor — cursor for the next page (null if no more results)orderbooks — array of orderbook objects:
baseToken — base token addressquoteToken — quote token addressbookKey — unique orderbook identifier (used as cursor)bestAskTick — best (lowest) ask price tickbestBidTick — best (highest) bid price tickspread — difference between best ask and best bid ticksdex_getOrderbooks method is essential for:
dex_getOrderbooks code examplesconst ethers = require('ethers');
const NODE_URL = "CHAINSTACK_NODE_URL";
const provider = new ethers.JsonRpcProvider(NODE_URL);
const getOrderbooks = async () => {
// Get all orderbooks
const result = await provider.send("dex_getOrderbooks", [{
limit: 10
}]);
console.log(`Found ${result.orderbooks.length} orderbooks`);
for (const book of result.orderbooks) {
console.log(`Pair: ${book.baseToken} / ${book.quoteToken}`);
console.log(` Best Bid Tick: ${book.bestBidTick}`);
console.log(` Best Ask Tick: ${book.bestAskTick}`);
console.log(` Spread: ${book.spread} ticks`);
}
};
getOrderbooks();
Was this page helpful?