OkxTR

OkxTR

OkxTR API Information

OkxTR Api Link: https://www.okx.com/docs-v5/en/?python#overview

Production Trading Services

Production Trading URL

REST: https://www.okx.com

Transaction Timeouts

Orders may not be processed in time due to network delay or busy OKX servers. You can configure the request expiration using expTime.

  • If expTime is set in Place (multiple) orders or Amend (multiple) orders, and the server’s current time is after expTime, the request will not be processed.

Rate Limits

The OKX API applies rate limits to protect the platform:

  • If a request is rejected due to rate limit → Error code 50011 “Rate limit reached. Please refer to API documentation and throttle requests accordingly”

Each endpoint has its own rate limit.

Rate Limit Rules

  • WebSocket login & subscription: per connection
  • Public REST (unauthenticated): per IP address
  • Private REST: per User ID (each sub-account has a separate User ID)
  • WebSocket order management: per User ID

API Class Error Codes

Error Code HTTP Status Error Message
50100 400 API frozen, please contact customer service.
50101 401 APIKey does not match current environment.
50102 401 Timestamp request expired.
50103 401 Request header “OK-ACCESS-KEY” cannot be empty.
50104 401 Request header “OK-ACCESS-PASSPHRASE” cannot be empty.
50105 401 Request header “OK-ACCESS-PASSPHRASE” incorrect.
50106 401 Request header “OK-ACCESS-SIGN” cannot be empty.
50107 401 Request header “OK-ACCESS-TIMESTAMP” cannot be empty.
50108 401 Exchange ID does not exist.
50109 401 Exchange domain does not exist.
50110 401 Your IP {param0} is not included in your API key’s IP whitelist.
50111 401 Invalid OK-ACCESS-KEY.
50112 401 Invalid OK-ACCESS-TIMESTAMP.
50113 401 Invalid signature.
50114 401 Invalid authorization.
50115 405 Invalid request method.
50116 200 Fast API is allowed to create only one API key
50118 200 To link the app using your API key, your broker needs to share their IP to be whitelisted
50119 200 API key doesn’t exist
50120 200 This API key doesn’t have permission to use this function
50121 200 You can’t access our services through the IP address ({param0})
50122 200 Order amount must exceed minimum amount

RCXT OkxTR API Information

There is 1 Base Endpoint for the OkxTR exchange:

  • apiUrl: tr.okx.com

Rate Limits

The rate limit set for each endpoint on the Bingx exchange is as follows:

Limit (1 minute) Spot Margin Usd Futures Coin Futures TransferIn TransferOut Ticker
Fetch Balances 1 Request Weight 1 Request Weight 1 Request Weight
Fetch Orders 10 Request Weight 5 Request Weight 5 Request Weight
Fetch Trades 10 Request Weight
Fetch DepositWithdrawals 10 Request Weight 10 Request Weight
Ticker 100 Request Weight

Fetch Balances

Spot Balance
  • The Base Endpoint is apiUrl (tr.okx.com).
  • The Endpoint used is /api/v5/account/balance.
  • The RCXT Endpoint is api/v1/okx-tr/balances.

The user sends a GET request to query the OkxTR wallet balances. This request must include the required header parameters:

  • The apiKey and secretKey values are taken from the header.

  • Limiter:

    • Each API endpoint is assigned a specific Request Weight value. The Request Weight value for Spot Balance is 1.
Usd Futures Balance
  • The Base Endpoint is apiUrl (tr.okx.com).
  • The Endpoint used is /api/v5/asset/balances.
  • The RCXT Endpoint is api/v1/okx-tr/balances.

The user sends a GET request to query the OkxTR wallet balances. This request must include the required header parameters:

  • The apiKey and secretKey values are taken from the header.

  • Limiter:

    • Each API endpoint is assigned a specific Request Weight value. The Request Weight value for Usd Futures Balance is 1.
Coin Futures Balance
  • The Base Endpoint is apiUrl (tr.okx.com).
  • The Endpoint used is /api/v5/asset/balances.
  • The RCXT Endpoint is api/v1/okx-tr/balances.

The user sends a GET request to query the OkxTR wallet balances. This request must include the required header parameters:

  • The apiKey and secretKey values are taken from the header.

  • Limiter:

    • Each API endpoint is assigned a specific Request Weight value. The Request Weight value for Coin Futures Balance is 1.

Response Example:

{
  "spot": [
    {
      "coin": "BTTC", #asset
      "total": "208850.4"
    }
  ],
  "margin": null,
  "isolatedMargin": null,
  "futures": [
    {
      "coin": "USDT", # asset
      "total": "0.03733590"
    },
    {
      "coin": "DOGE", #asset
      "total": "2000.00000000"
    }
  ],
  "earnings": null
}

Fetch Trades

Spot Trades
  • The Base Endpoint is apiUrl (tr.okx.com).
  • The Endpoint used is /api/v5/trade/fills-history.
  • The RCXT Endpoint is api/v1/okx-tr/trades.

The user sends a GET request to query the OkxTR Spot trades. This request must include the required header parameters:

  • The apiKey and secretKey values are taken from the header.

  • The following query parameters are required:

    • startTime: The date from which we want to fetch data.
    • symbol: The symbol of the pair used in the trade (e.g., BTCUSDT).
    • orderId: The order ID used to filter orders.
    • cursor: Used for pagination, specifies which page to fetch.
    • type: The type is set to spot for Spot Trades.
  • Limiter:

    • Each API endpoint is assigned a specific Request Weight value. The Request Weight value for Spot Trades is 1.
isolated Margin Trades
  • The Base Endpoint is apiUrl (tr.okx.com).
  • The Endpoint used is /api/v5/account/bills-archive.
  • The RCXT Endpoint is api/v1/okx-tr/trades.

The user sends a GET request to query the OkxTR Spot trades. This request must include the required header parameters:

  • The apiKey and secretKey values are taken from the header.

  • The following query parameters are required:

    • startTime: The date from which we want to fetch data.
    • symbol: The symbol of the pair used in the trade (e.g., BTCUSDT).
    • orderId: The order ID used to filter orders.
    • cursor: Used for pagination, specifies which page to fetch.
    • type: The type is set to iMargin for Isolated Margin Trades.
  • Limiter:

    • Each API endpoint is assigned a specific Request Weight value. The Request Weight value for Isolated Margin Trades is 1.
Usd Futures Trades
  • The Base Endpoint is apiUrl (tr.okx.com).
  • The Endpoint used is /api/v5/trade/fills-history.
  • The RCXT Endpoint is api/v1/okx-tr/trades.

The user sends a GET request to query the OkxTR Spot trades. This request must include the required header parameters:

  • The apiKey and secretKey values are taken from the header.

  • The following query parameters are required:

    • startTime: The date from which we want to fetch data.
    • symbol: The symbol of the pair used in the trade (e.g., BTCUSDT).
    • orderId: The order ID used to filter orders.
    • cursor: Used for pagination, specifies which page to fetch.
    • type: The type is set to uFutures for Usd Futures Trades.
  • Limiter:

    • Each API endpoint is assigned a specific Request Weight value. The Request Weight value for Usd Futures Trades is 1.
Coin Futures Trades
  • The Base Endpoint is apiUrl (tr.okx.com).
  • The Endpoint used is /api/v5/trade/fills-history.
  • The RCXT Endpoint is api/v1/okx-tr/trades.

The user sends a GET request to query the OkxTR Spot trades. This request must include the required header parameters:

  • The apiKey and secretKey values are taken from the header.

  • The following query parameters are required:

    • startTime: The date from which we want to fetch data.
    • symbol: The symbol of the pair used in the trade (e.g., BTCUSDT).
    • orderId: The order ID used to filter orders.
    • cursor: Used for pagination, specifies which page to fetch.
    • type: The type is set to cFutures for Coin Futures Trades.
  • Limiter:

    • Each API endpoint is assigned a specific Request Weight value. The Request Weight value for Coin Futures Trades is 1.

Response Example:

{
  "trades": [
    {
      "orderId": "226664511", #orderId
      "tradeId": "27082209",
      "isBuyer": false,
      "isMaker": false,
      "price": "0.07610000", #price
      "quantity": "199.90000000", #origQty
      "symbol": "ACAUSDT", #symbol
      "time": 1737552748284, #time
      "commission": "0.01521239", #fee
      "commissionCurrency": "USDT" #side
    }
  ],
  "cursor": ""
}

Fetch Orders

Spot Orders
  • The Base Endpoint is apiUrl (tr.okx.com).
  • The Endpoint used is /api/v5/trade/orders-history-archive.
  • The RCXT Endpoint is api/v1/okx-tr/orders.

The user sends a GET request to query OkxTR Spot orders. This request must include the required header parameters:

  • The apiKey and secretKey values are taken from the header.

  • The following query parameters are required:

    • startTime: The date from which we want to fetch data.
    • symbol: The symbol of the pair used in the trade (e.g., BTCUSDT).
    • orderId: The order ID used to filter orders.
    • cursor: Used for pagination, specifies which page to fetch.
    • type: Options include spot, iMargin, margin, cfutures, ufutures. spot should be selected for Spot Orders.
  • Limiter:

    • Each API endpoint is assigned a specific Request Weight value. The Request Weight value for Spot Orders is 1.
Margin Orders
  • The Base Endpoint is apiUrl (tr.okx.com).
  • The Endpoint used is /api/v5/trade/orders-history-archive.
  • The RCXT Endpoint is api/v1/okx-tr/orders.

The user sends a GET request to query OkxTR Margin orders. This request must include the required header parameters:

  • The apiKey and secretKey values are taken from the header.

  • The following query parameters are required:

    • startTime: The date from which we want to fetch data.
    • symbol: The symbol of the pair used in the trade (e.g., BTCUSDT).
    • orderId: The order ID used to filter orders.
    • cursor: Used for pagination, specifies which page to fetch.
    • type: Options include spot, iMargin, margin, cfutures, ufutures. margin should be selected for Margin Orders.
  • Limiter:

    • Each API endpoint is assigned a specific Request Weight value. The Request Weight value for Margin Orders is 1.
Isolated Margin Orders
  • The Base Endpoint is apiUrl (tr.okx.com).
  • The Endpoint used is /api/v5/trade/orders-history-archive.
  • The RCXT Endpoint is api/v1/okx-tr/orders.

The user sends a GET request to query OkxTR Isolated Margin orders. This request must include the required header parameters:

  • The apiKey and secretKey values are taken from the header.

  • The following query parameters are required:

    • startTime: The date from which we want to fetch data.
    • symbol: The symbol of the pair used in the trade (e.g., BTCUSDT).
    • orderId: The order ID used to filter orders.
    • cursor: Used for pagination, specifies which page to fetch.
    • type: Options include spot, iMargin, margin, cfutures, ufutures. iMargin should be selected for Isolated Margin Orders.
  • Limiter:

    • Each API endpoint is assigned a specific Request Weight value. The Request Weight value for Isolated Margin Orders is 1.
Usd Futures Orders
  • The Base Endpoint is apiUrl (tr.okx.com).
  • The Endpoint used is /api/v5/trade/orders-history-archive.
  • The RCXT Endpoint is api/v1/okx-tr/orders.

The user sends a GET request to query OkxTR Usd Futures orders. This request must include the required header parameters:

  • The apiKey and secretKey values are taken from the header.

  • The following query parameters are required:

    • startTime: The date from which we want to fetch data.
    • symbol: The symbol of the pair used in the trade (e.g., BTCUSDT).
    • orderId: The order ID used to filter orders.
    • cursor: Used for pagination, specifies which page to fetch.
    • type: Options include spot, iMargin, margin, cfutures, ufutures. uFutures should be selected for Usd Futures Orders.
  • Limiter:

    • Each API endpoint is assigned a specific Request Weight value. The Request Weight value for Usd Futures Orders is 1.
Coin Futures Orders
  • The Base Endpoint is apiUrl (tr.okx.com).
  • The Endpoint used is /api/v5/trade/orders-history-archive.
  • The RCXT Endpoint is api/v1/okx-tr/orders.

The user sends a GET request to query OkxTR Coin Futures orders. This request must include the required header parameters:

  • The apiKey and secretKey values are taken from the header.

  • The following query parameters are required:

    • startTime: The date from which we want to fetch data.
    • symbol: The symbol of the pair used in the trade (e.g., BTCUSDT).
    • orderId: The order ID used to filter orders.
    • cursor: Used for pagination, specifies which page to fetch.
    • type: Options include spot, iMargin, margin, cfutures, ufutures. cFutures should be selected for Coin Futures Orders.
  • Limiter:

    • Each API endpoint is assigned a specific Request Weight value. The Request Weight value for Coin Futures Orders is 1.

Response Example:

{
  "orders": [
    {
      "orderId": "1881364520706670592", #orderId
      "symbol": "XRPUSDT", #symbol
      "type": "MARKET", #type
      "price": "3.335", #price
      "side": "SELL", #side
      "time": 1737387230537, #time
      "status": "CLOSED", #status
      "executedQuantity": "2.7", #executedQty
      "quantity": "2.7" #origiQty
    }
  ],
  "cursor": ""
}

Fetch DepositWithdrawals

Transfer In
  • The Base Endpoint is apiUrl (tr.okx.com).
  • The Endpoint used is /api/v5/asset/deposit-history.
  • The RCXT Endpoint is api/v1/okx-tr/deposit-withdraw-history.

The user sends a GET request to query OkxTR transfer-in data. This request must include the required header parameters:

  • The apiKey and secretKey values are taken from the header.

  • The following query parameters are required:

    • startTime: The date from which we want to fetch data.
    • fromId: The transfer ID used to filter the specific transfer.
    • type: Options include transferIn and transferOut. transferIn should be selected for Transfer In.
  • Limiter:

    • Each API endpoint is assigned a specific Request Weight value. The Request Weight value for Transfer In is 1.
Transfer Out
  • The Base Endpoint is apiUrl (tr.okx.com).
  • The Endpoint used is /api/v5/asset/deposit-history.
  • The RCXT Endpoint is api/v1/okx-tr/deposit-withdraw-history.

The user sends a GET request to query OkxTR transfer-in data. This request must include the required header parameters:

  • The apiKey and secretKey values are taken from the header.

  • The following query parameters are required:

    • startTime: The date from which we want to fetch data.
    • fromId: The transfer ID used to filter the specific transfer.
    • type: Options include transferIn and transferOut. transferIn should be selected for Transfer In.
  • Limiter:

    • Each API endpoint is assigned a specific Request Weight value. The Request Weight value for Transfer In is 1.