Orders

The Orders API allows you to create, cancel, and manage orders on the Xmarket platform.

Create Order

Create a new order in orderbook.

Authentication

All order operations require authentication using your API key in the x-api-key header:

Create Batch Order

Cancel Order

Cancel an existing open order.

Batch Create Orders

Create multiple orders in a single request for improved performance.

Cancel Order

Cancel an existing open order.

Cancel All Orders

Cancel all open orders for a specific market.

Batch Cancel Orders

Cancel multiple orders by their order IDs in a single request.

Get My Orders

Retrieve your orders with pagination and filtering options.

Get Market Orders

Retrieve all orders in a specific market, filtered by status and paginated.

Order Types

Limit Orders

  • Execute at a specific price or better

  • May not fill immediately

  • Provide liquidity to the market

Market Orders

  • Execute immediately at best available price

  • Guaranteed to fill (if liquidity exists)

  • Take liquidity from the market

Order Status

Orders can have the following statuses:

Status
Description

open

Order is active and waiting to be filled

partially_filled

Some quantity has been filled

filled

Order completely executed

cancelled

Order cancelled by user

expired

Order expired based on expiredAt time

Code Examples

Create a Limit Order

Batch Create Orders

Cancel Multiple Orders

Get Market Orders

Python Example - Create and Monitor Order

Best Practices

  1. Order Validation: Always validate order parameters before submission

  2. Batch Operations: Use batch endpoints when creating/cancelling multiple orders

  3. Error Handling: Implement robust error handling for all API calls

  4. Rate Limiting: Respect API rate limits to avoid being throttled

  5. Order Management: Track your open orders and cancel outdated ones

  6. Price Checks: Verify prices are within valid range (0 < price < 1)

  7. Signature Security: Never expose your private key; sign orders securely

  8. Idempotency: Consider implementing idempotency for order creation to prevent duplicates

Performance Optimization

  • Use batch create when placing multiple orders to reduce API calls

  • Use batch cancel to efficiently close multiple positions

  • Poll my-orders endpoint instead of individual order status checks

  • Cache market data to validate orders before submission

Last updated

Was this helpful?