Querying the Orderbook

The Limit Order SDK provides a built-in Api class for querying orders from the 1inch Orderbook. You can retrieve orders by hash, by maker address, or browse all active orders with pagination support.

Prerequisites

You need:

  • A 1inch API key (get one at 1inch Business)
  • The @1inch/limit-order-sdk package installed

No wallet or private key is required for read-only queries.

Setting up the API client

JavaScript
1
2
3
4
5
6
7
import { Api, FetchProviderConnector, CursorPager } from "@1inch/limit-order-sdk";

const api = new Api({
  networkId: 1, // Ethereum mainnet
  authKey: "your-api-key",
  httpConnector: new FetchProviderConnector()
});

Query by order hash

If you have an order hash from a previous submission, you can retrieve its full details:

JavaScript
1
2
3
4
5
const order = await api.getOrderByHash(orderHash);
console.log("Maker Asset:", order.data.makerAsset);
console.log("Taker Asset:", order.data.takerAsset);
console.log("Making Amount:", order.data.makingAmount);
console.log("Taking Amount:", order.data.takingAmount);

Query by maker address

To retrieve all orders created by a specific wallet address, use getOrdersByMaker with pagination:

JavaScript
1
2
3
4
5
6
7
8
9
const response = await api.getOrdersByMaker(makerAddress, {
  pager: new CursorPager({ limit: 10 }),
  statuses: [1] // 1 = active orders only
});

for (const order of response.items) {
  console.log("Maker Asset:", order.data.makerAsset);
  console.log("Taking Amount:", order.data.takingAmount);
}

Status codes

Status Meaning
1 Active
2 Filled
3 Expired
4 Cancelled

Query all active orders

To browse the full orderbook, use getAllOrders with pagination:

JavaScript
1
2
3
4
5
6
const response = await api.getAllOrders({
  pager: new CursorPager({ limit: 5 }),
  statuses: [1]
});

console.log(`Found ${response.items.length} active orders`);

Full working example

Did you find what you need?