Skip to main content

Querying Orders

Get a Single Order

import { Orderbook } from '@imtbl/orderbook';

const { result: order } = await orderbook.getListing(orderId);

console.log({
  id: order.id,
  status: order.status,
  price: order.buy.amount,
  seller: order.accountAddress,
  tokenId: order.sell.tokenId,
});

List Orders for a Collection

import { Orderbook, OrderStatusName } from '@imtbl/orderbook';

const { result } = await orderbook.listListings({
  sellItemContractAddress: NFT_CONTRACT,
  status: OrderStatusName.ACTIVE,
  pageSize: 50,
});

for (const listing of result) {
  console.log(`Token #${listing.sell.tokenId}: ${listing.buy.amount} IMX`);
}

Pagination

let cursor: string | undefined;

do {
  const { result, page } = await orderbook.listListings({
    sellItemContractAddress: NFT_CONTRACT,
    status: OrderStatusName.ACTIVE,
    pageSize: 100,
    pageCursor: cursor,
  });
  
  for (const listing of result) {
    console.log(listing.id);
  }
  
  cursor = page.nextCursor;
} while (cursor);

Order Status

For complete order status definitions and lifecycle, see Order Lifecycle.

Fill Status

For fill status details and tracking partial fills, see Fill Orders: Fill Status.

Cancelling Orders

For detailed cancellation methods, race conditions, and best practices, see Cancel Orders.

Webhooks

Get real-time notifications for order events. Configure webhooks in Hub. For implementation details, see the webhook documentation.
EventTrigger
imtbl_order_updatedOrder status changed
imtbl_activity_saleTrade completed

Webhook Payload Example

{
  "event_name": "imtbl_order_updated",
  "data": {
    "id": "order-123",
    "status": "FILLED",
    "sell": {
      "type": "ERC721",
      "contract_address": "0x...",
      "token_id": "456"
    },
    "buy": {
      "type": "NATIVE",
      "amount": "1000000000000000000"
    }
  }
}

Next Steps

Create Listings

Learn how to create NFT listings

Fill Orders

Buy NFTs by filling orders

Cancel Orders

Cancel listings with soft or hard cancels

Fees

Understand fee structure and calculations