Skip to main content
๐Ÿ“– Tronsell Wiki

Order Management API Guide: Place, Cancel & Track Orders

Complete guide to Order Management APIs on cryptocurrency exchanges โ€” learn how to place, cancel, and track orders programmatically, manage open orders, and build reliable order management systems.

๐Ÿ“‹ Order Management at a Glance
What It Does Place, cancel, and track orders programmatically
Order Types Market, Limit, Stop-Limit, Take Profit
Key Endpoints Place, Cancel, Open Orders, Order History
Authentication API key with Trade permissions
Best For Trading bots, automated strategies
Tracking Client order IDs, WebSocket streams

๐Ÿ“‹ What is an Order Management API?

An Order Management API is a programmatic interface that allows you to place, cancel, and track orders on a cryptocurrency exchange. It is the core component of any trading bot or automated trading system, enabling you to:

  • Place orders โ€” Market, limit, stop-limit, and take profit orders.
  • Cancel orders โ€” Cancel individual orders or all open orders.
  • Track orders โ€” Check order status, view open orders, and retrieve order history.
  • Manage positions โ€” Monitor and adjust your trading positions.

Order Management APIs are authenticated endpoints โ€” they require an API key with Trade permissions. They are the backbone of algorithmic trading, allowing you to execute strategies without manual intervention.

๐Ÿ’ก Why Order Management APIs are Essential
  • Speed: Execute trades in milliseconds.
  • Automation: Run strategies 24/7 without manual oversight.
  • Precision: Place orders with exact parameters.
  • Scalability: Manage multiple orders and trading pairs simultaneously.
5+
Order types supported
1000+
Orders per second (scalable)
24/7
Automated trading
Trade
Required permission

๐Ÿ“Š Order Types Supported by APIs

Most exchanges support a range of order types through their APIs. Here are the most common ones.

๐Ÿ“ˆ
Market Order

Executes immediately at the current market price. Requires only quantity. Best for when you need to enter or exit a position quickly.

๐Ÿ“‰
Limit Order

Executes only at a specific price or better. Requires quantity and price. Gives you price control but may not fill immediately.

โ›”
Stop-Limit Order

Triggers a limit order when the stop price is reached. Used for risk management and breakout trading. Requires stop price and limit price.

๐ŸŽฏ
Take Profit Order

Automatically closes a position when a profit target is reached. Often used with stop-loss orders for risk management.

๐Ÿ”„
OCO Order

One-Cancels-Other โ€” combines a limit order and a stop-limit order. When one executes, the other is automatically canceled.

โšก
Post-Only Order

Ensures the order adds liquidity to the order book. It will be rejected if it would execute immediately as a taker order.

๐Ÿ’ก Choosing the Right Order Type

Use MARKET orders for speed and certainty of execution. Use LIMIT orders for price control and to avoid slippage. Use STOP-LIMIT and TAKE PROFIT orders for risk management.

๐Ÿ“‹ Key Order Management Endpoints

Here are the most important order management endpoints across major exchanges.

Endpoint Description Method Requires Auth?
/api/v3/order Place a new order POST Yes (Trade)
/api/v3/order Cancel an order DELETE Yes (Trade)
/api/v3/openOrders Get all open orders GET Yes (Read)
/api/v3/allOrders Get order history GET Yes (Read)
/api/v3/order Query a specific order GET Yes (Read)
/api/v3/openOrders Cancel all open orders DELETE Yes (Trade)
/api/v3/order/amendment Modify an existing order PUT/PATCH Yes (Trade)
๐Ÿ’ก Note

Endpoint URLs vary by exchange. Binance uses /api/v3/, OKX uses /api/v5/, and Bybit uses /v5/. Always refer to the exchange's official API documentation for accurate endpoints.

๐Ÿ“ Placing Orders with the API

Here's how to place different types of orders using the API.

Market Order

POST /api/v3/order
Parameters: symbol=BTCUSDT, side=BUY, type=MARKET, quantity=0.001

Limit Order

POST /api/v3/order
Parameters: symbol=BTCUSDT, side=BUY, type=LIMIT, quantity=0.001, price=60000

Stop-Limit Order

POST /api/v3/order
Parameters: symbol=BTCUSDT, side=SELL, type=STOP_LOSS_LIMIT, quantity=0.001, price=65000, stopPrice=64000

Using Client Order IDs

Most exchanges support client order IDs (also called custom order IDs or newClientOrderId). This allows you to assign a unique ID to each order, making it easier to track orders across your systems.

POST /api/v3/order
Parameters: symbol=BTCUSDT, side=BUY, type=LIMIT, quantity=0.001, price=60000, newClientOrderId=myOrder123
๐Ÿ’ก Client Order ID Best Practices
  • Use unique IDs for each order (e.g., timestamp + sequence number).
  • Store your client order IDs in your database to track order status.
  • Query orders by client order ID instead of exchange order ID.

โŒ Canceling Orders

Canceling orders is essential for managing open positions and adjusting strategies. Here's how to cancel orders via the API.

Cancel a Specific Order

DELETE /api/v3/order
Parameters: symbol=BTCUSDT, orderId=123456789 (or clientOrderId=myOrder123)

Cancel All Open Orders

DELETE /api/v3/openOrders
Parameters: symbol=BTCUSDT (optional, cancels all orders if omitted)
โš ๏ธ Important

If you attempt to cancel an order that has already been fully filled or partially filled, the exchange will return an error indicating the order cannot be canceled because it's no longer open. Always check the order status before attempting to cancel.

๐Ÿ“Š Tracking Orders

Tracking orders is critical for monitoring your trading activity. Here are the key methods.

Get Open Orders

GET /api/v3/openOrders
Parameters: symbol=BTCUSDT (optional, returns all if omitted)

Query a Specific Order

GET /api/v3/order
Parameters: symbol=BTCUSDT, orderId=123456789 (or clientOrderId=myOrder123)

Get Order History

GET /api/v3/allOrders
Parameters: symbol=BTCUSDT, limit=100

Order Status Values

  • NEW: Order has been accepted and is pending.
  • PARTIALLY_FILLED: Part of the order has been executed.
  • FILLED: The order has been fully executed.
  • CANCELED: The order was canceled by the user.
  • REJECTED: The order was rejected by the exchange.
  • EXPIRED: The order expired (e.g., GTC orders).
๐Ÿ’ก Real-Time Order Tracking

For real-time order updates, use WebSocket streams (e.g., Binance's user data stream). This provides instant notifications when an order is filled, canceled, or updated, without polling REST endpoints.

โš ๏ธ Error Handling Best Practices

Order management APIs can return various errors. Handling them gracefully is critical for building reliable trading systems.

Error Cause Solution
Insufficient balance Not enough funds in your account Check balance before placing orders
Invalid symbol Trading pair doesn't exist or is inactive Verify the symbol is valid
Invalid quantity Quantity is below minimum or not a multiple of step size Check exchange's filters for the trading pair
Invalid price Price is below minimum or not a multiple of tick size Check exchange's filters for the trading pair
Order not found Trying to cancel/query an order that doesn't exist Verify order ID before canceling
Order not modifiable Trying to modify an order that is already filled or canceled Check order status before modifying
HTTP 429 (Rate Limit) Too many requests Implement exponential backoff
๐Ÿ›ก๏ธ Error Handling Strategy
  • Validate inputs before sending requests.
  • Check response codes โ€” 200 means success, 4xx means client error, 5xx means server error.
  • Implement retry logic with exponential backoff for transient errors.
  • Log all errors for debugging and monitoring.
  • Store order IDs to handle follow-up actions.

๐Ÿ† Best Practices for Order Management APIs

Follow these best practices to build reliable order management systems.

  • 1
    Use client order IDs

    Assign unique client order IDs to every order. This makes it easy to track orders across your systems without relying on exchange order IDs.

  • 2
    Check balance before placing orders

    Always verify you have sufficient available balance before placing an order to avoid "insufficient balance" errors.

  • 3
    Store order IDs and status

    Maintain a local database of your orders with their IDs, status, and details. This helps with reconciliation and error recovery.

  • 4
    Use WebSocket for real-time updates

    Instead of polling REST endpoints for order status, use WebSocket streams for instant order updates.

  • 5
    Implement idempotency

    Use client order IDs to ensure that duplicate order requests don't result in duplicate orders. This is critical for preventing double orders.

  • 6
    Handle partial fills

    Orders can be partially filled. Your system should handle partial fills gracefully โ€” update the order status and remaining quantity.

โ“ Frequently Asked Questions About Order Management APIs

What is an Order Management API?

An Order Management API is a programmatic interface that allows you to place, cancel, and track orders on a cryptocurrency exchange. It provides endpoints for creating market and limit orders, canceling orders, retrieving open orders, and accessing order history.

What order types can I place using the API?

Most exchanges support: MARKET orders (execute immediately at current price), LIMIT orders (execute at a specific price or better), STOP-LIMIT orders (trigger a limit order when a stop price is reached), TAKE PROFIT orders, and sometimes advanced order types like OCO (One-Cancels-Other).

How do I track my orders using the API?

You can track orders using several methods: 1) Get all open orders to see pending orders, 2) Query a specific order by order ID to check its status, 3) Use WebSocket streams for real-time order updates, 4) Retrieve order history for completed orders.

What happens if I cancel an order that's already filled?

If you attempt to cancel an order that has already been fully filled or partially filled, the exchange will return an error indicating the order cannot be canceled because it's no longer open. Always check the order status before attempting to cancel.

Can I use client order IDs to track my orders?

Yes, most exchanges support client order IDs (also called custom order IDs). You can assign a unique ID to each order when placing it, making it easier to track orders across your systems without relying on the exchange's order ID.

What permissions do I need for order management APIs?

For placing and canceling orders, you need Trade permission. For querying open orders and order history, Read permission is sufficient. Never enable withdrawal permissions on keys used for trading.

Can I modify an existing order using the API?

Some exchanges support order modification (e.g., changing price or quantity). This is done via an order amendment endpoint (PUT/PATCH). However, not all exchanges support this โ€” check the exchange's documentation. If not supported, cancel the existing order and place a new one.

What are the rate limits for order management APIs?

Rate limits vary by exchange and are typically lower for authenticated endpoints than public ones. Binance has 1200 weight/min, OKX has 50 requests/sec, Bybit has 50 requests/sec. Order placement requests consume more weight than simple queries. Always implement throttling to stay within limits.

๐Ÿ“‹ Build Reliable Order Management Systems

Master Order Management APIs to place, cancel, and track orders programmatically. Build trading bots with client order IDs, WebSocket tracking, and robust error handling.