GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing api.hitbtc.com (truncated) — API Documentation

NAV
  • ABOUT HitBTC API
  • DEVELOPMENT GUIDE
    • API URLs
    • API Explorer
    • DateTime Format
    • Date Format
    • Number Format
    • Custom Formats
    • Pagination
  • RATE LIMITS
    • Per IP Address
    • Per Account
  • CHANGELOG
    • 28.09.2026
    • 27.08.2026
    • 06.01.2025
    • 16.12.2024
    • 29.11.2024
    • 22.10.2024
    • 02.10.2024
    • 04.09.2024
    • 17.05.2024
    • 15.05.2024
    • 10.05.2024
    • 05.03.2024
    • 01.02.2024
    • 02.11.2023
    • 09.10.2023
    • 25.09.2023
    • 25.07.2023
    • 07.07.2023
    • 31.05.2023
    • 19.05.2023
    • 15.11.2022
    • 28.07.2022
    • 16.03.2022
    • 12.01.2022
    • 27.12.2021
    • 23.12.2021
    • 08.12.2021
    • 23.11.2021
    • 19.11.2021
    • 10.11.2021
    • 25.08.2021
    • 24.08.2021
    • 30.07.2021
    • 28.07.2021
  • BEST PRACTICES
    • Request Parameters
    • HTTP Persistent Connection
    • Retrieving and Updating Account State
  • REST API REFERENCE
    • HTTP Status Codes
    • Error Response
  • Market Data
    • Currencies
    • Symbols
    • Tickers
    • Prices
    • Trades
    • Order Books
    • Candles
    • Futures Info
    • Funding History
    • Futures Index Price Candles
    • Futures Mark Price Candles
    • Futures Premium Index Candles
    • Futures Open Interest Candles
  • Authentication
    • Basic
    • HS256
  • Spot Trading
    • Order Model
    • Get Spot Trading Balance
    • Get All Active Spot Orders
    • Get Active Spot Order
    • Create New Spot Order
    • Create New Spot Order List
    • Replace Spot Order
    • Cancel All Spot Orders
    • Cancel Spot Order
    • Get All Trading Commissions
    • Get Trading Commission
  • Spot Trading History
    • Spot Orders History
    • Spot Trades History
  • Margin Settings
    • Auto Margin Management
    • Auto Margin Replenishment
    • Get Margin Settings
    • Set Auto Margin Management
    • Set Auto Margin Replenishment
  • Margin Trading
    • Margin Order Model
    • Margin Account Model
    • Get All Margin Accounts
    • Get Isolated Margin Account
    • Get Cross–margin Account
    • Create/Update Margin Account
    • Close Margin Positions
    • Close Margin Position
    • Get Active Margin Orders
    • Get Active Margin Order
    • Create Margin Order
    • Create New Margin Order List
    • Replace Margin Order
    • Cancel All Margin Orders
    • Cancel Margin Order
    • Get Margin Position Parameters
  • Margin Trading History
    • Margin Orders History
    • Margin Trades History
    • Margin Positions History
    • Margin Clearing Details
  • Futures Trading
    • Futures Order Model
    • Futures Margin Account Model
    • Get Trading Balance
    • Get Futures Margin Accounts
    • Get Futures Margin Account
    • Get Futures Cross–margin Account
    • Create/Update Margin Account
    • Set Position Leverage
    • Close All Futures Margin Positions
    • Close Futures Margin Position
    • Get Active Futures Orders
    • Get Active Futures Order
    • Create Futures Order
    • Create New Futures Order List
    • Cancel Futures Orders
    • Replace Futures Order
    • Cancel Futures Order
    • Get Futures Position Parameters
    • Get All Trading Commissions
    • Get Trading Commission
  • Futures Trading History
    • Futures Orders History
    • Futures Trades History
    • Futures Positions History
    • Futures Clearing Details
  • User Management
    • Get API Keys
  • Wallet Management
    • Wallet Balance
    • Get Whitelisted Addresses
    • Get Deposit Crypto Address
    • Generate Deposit Crypto Address
    • Last 10 Deposit Crypto Addresses
    • Last 10 Withdrawal Crypto Addresses
    • Withdraw Crypto
    • Convert Between Currencies
    • Withdraw Crypto Commit or Rollback
    • Withdraw Crypto Cancel
    • Check If Crypto Address Belongs to Current Account
    • Transfer Between Wallet and Exchange
    • Transfer Money to Another User
    • Get Transactions History
    • Generate Transactions Report
    • Check If Offchain is Available
    • Estimate Withdrawal Fees
    • Estimate Withdrawal Fee
    • Bulk Estimate Withdrawal Fee
    • Get Withdrawal Fees Hash
    • Airdrops
    • Get Amount Locks
  • Subaccounts
    • Get Subaccounts List
    • Freeze Subaccount
    • Activate Subaccount
    • Transfer to Subaccount
    • Transfer to Super Account
    • Transfer Across Subaccounts
    • Get ACL Settings
    • Change ACL Settings
    • Get Subaccount Balance
    • Get Subaccount Crypto Address
  • SOCKET API REFERENCE
    • Connection
    • Ping
    • Request Object
    • Notification
    • Response Object
  • Socket Market Data
    • Subscriptions
    • Batch Notifications
    • Get Active Subscriptions
    • Subscribe to Trades
    • Subscribe to Candles
    • Subscribe to Converted Candles
    • Subscribe to Price Rates
    • Subscribe to Price Rates in Batches
    • Subscribe to Mini Ticker
    • Subscribe to Mini Ticker in Batches
    • Subscribe to Ticker
    • Subscribe to Ticker in Batches
    • Subscribe to Full Order Book
    • Subscribe to Partial Order Book
    • Subscribe to Partial Order Book in Batches
    • Subscribe to Top of Book
    • Subscribe to Top of Book in Batches
    • Subscribe to Futures Information
  • Socket Authentication
    • Basic
    • HS256
  • Socket Trading
  • Socket Spot Trading
    • Subscribe to Reports
    • Get Active Spot Orders
    • Place New Spot Order
    • Create New Spot Order List
    • Cancel Spot Order
    • Cancel/Replace Spot Order
    • Cancel Spot Orders
    • Subscribe to Spot Balances
    • Get Spot Trading Balances
    • Get Spot Trading Balance
    • Get Spot Fees
    • Get Spot Fee
  • Socket Margin Trading
    • Description
    • Subscribe to Reports
    • Get Margin Orders
    • Place New Margin Order
    • Create New Margin Order List
    • Cancel Margin Order
    • Cancel/Replace Margin Order
    • Get Margin Accounts
    • Create/Update Margin Account
    • Close Margin Position
  • Socket Futures Trading
    • Description
    • Subscribe to Reports
    • Get Active Futures Orders
    • Place New Futures Order
    • Create New Futures Order List
    • Cancel Futures Order
    • Cancel/Replace a Futures Order
    • Cancel Futures Order
    • Get Futures Accounts
    • Create/Update Futures Account
    • Set Position Leverage
    • Close Futures Position
    • Subscribe to Futures Balances
    • Get Futures Trading Balances
    • Get Futures Trading Balance
    • Get Futures Fees
    • Get Futures Fee
  • Socket Wallet Management
    • Description
    • Subscribe to Transactions
    • Subscribe to Wallet Balances
    • Request Wallet Balance
    • Get Transactions
  • Errors
    • Market Data
    • Authentication
    • Trading
    • Wallet Management

ABOUT HitBTC API

HitBTC REST & Streaming API version 3.0 provides programmatic access to HitBTC’s next generation trading engine.

We strongly recommend that our new customers use API version 3.0 to get the best trading experience. We also recommend that our current traders switch to the newest version 3.0.

API version 2.0 is still available. For detailed description refer to API v2.

To optimize API performance and provide better trading services, API version 1.0 is unavailable since 28.02.2022. All /api/1/ endpoints are affected.

By using the HitBTC API you confirm that you have read and accepted the API License Agreement.

DEVELOPMENT GUIDE

API URLs

REST https://api.hitbtc.com/api/3
Streaming Market Data wss://api.hitbtc.com/api/3/ws/public
Streaming Trading wss://api.hitbtc.com/api/3/ws/trading
Streaming Wallet wss://api.hitbtc.com/api/3/ws/wallet

Demo Environment (Sandbox):

REST https://api.demo.hitbtc.com/api/3
Streaming Market Data wss://api.demo.hitbtc.com/api/3/ws/public
Streaming Trading wss://api.demo.hitbtc.com/api/3/ws/trading
Streaming Wallet wss://api.demo.hitbtc.com/api/3/ws/wallet

API Explorer

You can explore the API using Swagger UI including methods requiring authorization.

DateTime Format

All timestamps are returned in ISO 8601 format or UNIX timestamp in milliseconds (UTC).

Example: "2024-04-03T10:20:49.315Z" or "1614815872000".

Date Format

Some timestamps are returned in ISO 8601 format which includes a calendar date only.

Example: "2024-04-03".

Number Format

All finance data, e.g., price, quantity, fee, etc., should be arbitrary precision numbers and have a string representation.

Example: "10.2000058".

Custom Formats

In nested JSON objects, child objects have custom formats which are described in tables below a place of the first occurrence.

Pagination

Parameter Description
limit Number of results per call.
offset Number of results offset.
sort Sort direction.
Accepted values: ASC (ascending order), DESC (descending order)
by Filter type.
Accepted values: id, timestamp
from Interval initial value.
If filter by timestamp is used, then parameter type is DateTime; otherwise — Number.
till Interval end value.
If filter by timestamp is used, then parameter type is DateTime; otherwise — Number.

RATE LIMITS

The maximum number requests per second (RPS) for specific calls can be limited by a rate limit and a burst limit.

The server will process a number of requests that do not exceed the sum of the rate limit and the burst limit within the 1-second sliding window.

For example, if the rate limit is 20 and the burst limit is 30, after the counter is reset, the server will accept up to 50 requests per second.
It is suggested to not exceed the rate limit in order to get a guaranteed reset of the counter each second. All residual requests below the burst limit are accumulated for the next 1–second period, making the resulting system behavior less predictable.

If both limits in total are exceeded, an HTTP 429 response is returned.

Requests are being counted per call (REST endpoint or WebSocket message) and:

  • per IP address — requests arrived from the same IP address regardless of the identity;
  • per account — requests sent under the same identity regardless of an API key, session, connection or IP address.

Per IP Address

REST API

Path Rate limit Burst limit
/* (default) 20 30
/public/* 30 50
/wallet/* 10 10
/spot/order/* 300 450
/margin/order/*,
/margin/account/*,
/margin/position/*
300 450
/futures/order/*,
/futures/account/*,
/futures/position/*
300 450
/transfer-convert/config 10 10

Socket API

Path Rate limit Burst limit
/ws/public 10 10
/ws/trading 10 10
/ws/wallet 10 10

Per Account

Order Limits

The total number of user's active and suspended orders cannot exceed 25000 across all symbols and 2000 — for a particular symbol.

After the limit is reached, new order requests will be rejected.

REST API

Path Rate limit Burst limit
/wallet/*,
/transfer-convert/config
20 30
/sub-account/* 20 30

Socket API

/ws/trading:

Method Rate limit Burst limit
login 5 —
spot_subscribe,
spot_unsubscribe,
spot_balance_subscribe,
spot_balance_unsubscribe
5 —
margin_subscribe, margin_unsubscribe 5 —
futures_subscribe,
futures_unsubscribe,
futures_balance
5 —
spot_balances,
spot_fee
20 10
margin_get_accounts 20 10
futures_get_accounts,
futures_balances,
futures_fee
20 10
spot_new_order,
spot_new_order_list,
spot_replace_order
300 200
margin_new_order,
margin_new_order_list,
margin_replace_order
300 200
futures_new_order,
futures_new_order_list,
futures_replace_order
300 200

/ws/wallet:

Method Rate limit Burst limit
login 2 10
subscribe_transactions,
unsubscribe_transactions,
subscribe_wallet_balances,
unsubscribe_wallet_balances,
wallet_balances,
wallet_balance,
transactions
5 10

CHANGELOG

28.09.2026

  • Added POST /api/3/report/{report_type}/{doc_type}: the transactions report as a CSV, XLSX or PDF file.

27.08.2026

  • AMM (auto margin management) and AMR (auto margin replenishment): the margin settings endpoints, the margin_auto parameter of new order requests, and the margin_auto and amr fields of margin account, position, and order models.

06.01.2025

  • Added an optional symbol parameter in:
    • GET /api/3/margin/history/positions;
    • GET /api/3/futures/history/positions.
  • Added the price_average field in the order model.

16.12.2024

  • Cross-margin accounts.

29.11.2024

  • Added order limits.

22.10.2024

  • Added endpoints:
    • GET /api/3/user/api-keys;
    • GET /api/3/wallet/crypto/address/white-list.
  • Added the attempt_hashes field in transaction history.

02.10.2024

  • Added endpoints:
    • POST /api/3/sub-account/transfer/sub-to-super;
    • POST /api/3/sub-account/transfer/sub-to-sub.
  • Added the ability to specify stop_price while replacing an order.

04.09.2024

  • Added endpoints:
    • GET /api/3/wallet/crypto/fee/withdraw/hash.

17.05.2024

  • Added endpoints:
    • POST /api/3/wallet/crypto/fee/estimate/bulk.

15.05.2024

  • Added last_activity_at field in the transaction model.
  • Added sorting transaction history by last_activity_at.

10.05.2024

  • Added fee_cumulative field in the position model and history.
  • Added close_position parameter in new order requests and responses.

05.03.2024

Added new 20018 error code.

01.02.2024

  • Changed the way of calculating rates returned by the GET /api/3/public/price/rate call.
  • Added new GET /api/3/public/converted/candles and GET /api/3/public/converted/candles/{symbol} endpoints which return candles converted to the given currency.
  • Changed the way of calculating rates published by the /price/rate feed.
  • Added a new converted/candles/{period} feed which returns candles converted to the given currency.
  • Added a new asset_id field in the network object that contains unique arbitrary data identifying the coin.

02.11.2023

Added support of multichain that allows specifying a combination of a currency and a base blockchain:

  • GET /api/3/public/currency:

    • added preferred_network request parameter;
    • added contract_address response field;
    • added networks response field;
    • properties of blockchain networks moved to items in networks.
  • POST /api/3/wallet/crypto/withdraw:

    • added network_code request body field.
  • GET /api/3/wallet/transactions:

    • added networks request parameter;
    • added network_code response field in native object;
    • added protocol_code response field in native object.
  • GET /api/3/wallet/crypto/address:

    • added network_code request parameter;
    • added network_code response field.
  • POST /api/3/wallet/crypto/address:

    • added network_code request body field;
    • added network_code response field.
  • GET /api/3/wallet/crypto/address/recent-deposit:

    • added network_code request parameter;
    • added network_code response field.
  • GET /api/3/wallet/crypto/address/recent-withdraw:

    • added network_code request parameter;
    • added network_code response field.
  • GET /api/3/wallet/crypto/fee/estimate:

    • added network_code request parameter.
  • GET /api/3/wallet/crypto/fee/levels:

    • added network_code request parameter.
  • GET /api/3/sub-account/crypto/address/{sub_account_id}/{currency}:

    • added network_code request parameter.
  • POST /api/3/wallet/crypto/fees/estimate:

    • added network_code request body field;
    • added networkCode response field.

09.10.2023

Added the commit risk score in the transaction history for deposits.

25.09.2023

Added a new operation_type field in the transaction history.

25.07.2023

Changed default TIF instructions for new orders.

07.07.2023

A new GET /api/3/wallet/crypto/fees/estimate endpoint.

31.05.2023

A new preferred_network filter in the GET /api/3/public/currency endpoint.

19.05.2023

WebSocket price/rate/ feeds.

15.11.2022

WebSocket balance feed.

28.07.2022

One-Triggers-Other (OTO) order lists.

16.03.2022

  • All-Or-None (AON), One-Cancels-Other (OCO), and One-Triggers-One-Cancels-Other (OTOCO) order lists.
  • Positions history endpoint.
  • Clearing details endpoint.

12.01.2022

Cash-settled futures.

27.12.2021

Take-profit orders.

23.12.2021

Reduce-only orders.

08.12.2021

Margin parameters.

23.11.2021

Amount locks.

19.11.2021

  • Hidden orders.
  • Increased rate limits up to 300 requests per second.

10.11.2021

  • The WebSocket request to get a single–currency trading balance.
  • Allowed to view and get trading history for disabled symbols.
  • Allowed to get trading history by several comma-separated symbols.

25.08.2021

Airdrops section.

24.08.2021

  • Added ability to request Wallet and Trading balance for a single currency.
  • subscribe_balance method replaced by subscribe_wallet_balances. Response was changed. Changes are backward compatible.
  • Eased key permissions for GET /api/3/margin/account, /api/3/margin/account/isolated/{symbol} and socket margin_get_accounts from "Place/cancel orders" to "Orderbook, History, Trading balance".
  • Eased key permissions for GET /api/3/futures/account, /api/3/futures/account/isolated/{symbol} and socket futures_get_accounts from "Place/cancel orders" to "Orderbook, History, Trading balance".
  • Added taker field to trade execution reports both for REST and WS.
  • Fixed market data subscription acknowledgment wasn't returned in some cases.
  • Fixed unsubscribe methods on trading subscriptions.

30.07.2021

  • Subaccounts section.
  • New endpoints for futures:
    • GET /api/3/public/futures/candles/open_interest to query open interest candles.
    • GET /api/3/public/futures/history/funding to query perpetual contracts funding history.

28.07.2021

API v3 initial release.

BEST PRACTICES

The HitBTC API development team strives to bring the best trading experience to API users. This manual contains a set of best practices for using the API as efficiently as possible.

Request Parameters

Pass a request payload (body) in POST requests and query parameters — in GET requests.

Passing parameters in a way different from the documentation is not supported.

HTTP Persistent Connection

The underlying TCP connection is kept active for multiple requests/responses. Subsequent requests will result in reduced latency as the TCP handshaking process is no longer required.

If you use the HTTP 1.0 client, please ensure it supports the Keep-Alive directive and submit the "Connection: Keep-Alive" header with a request.

Keep-Alive is a part of the HTTP/1.1 or HTTP/2 protocol and enabled by default on compliant clients. However, you will have to ensure your implementation does not set other values as the connection header.

Retrieving and Updating Account State

Use the Streaming API for real-time updates of orders, trades, and any transaction changes.

REST API REFERENCE

HTTP Status Codes

  • 200 OK. Successful request
  • 400 Bad Request. Returns JSON with the error message
  • 401 Unauthorized. Authorization is required or has been failed
  • 403 Forbidden. Action is forbidden
  • 404 Not Found. Data requested cannot be found
  • 429 Too Many Requests. Your connection has been rate limited
  • 500 Internal Server. Internal Server Error
  • 503 Service Unavailable. Service is down for maintenance
  • 504 Gateway Timeout. Request timeout expired

Error Response

{
  "error": {
    "code": 20001,
    "message": "Insufficient funds",
    "description": "Check that the funds are sufficient, given commissions"
  }
}

All error responses have error code and human-readable message fields. Some errors contain an additional description field.

Market Data

Currencies

Get Currencies

curl "https://api.hitbtc.com/api/3/public/currency"

Response:

{
  "BTC":
  {
    "full_name": "test",
    "crypto": true,
    "stable": true,
    "payin_enabled": true,
    "payout_enabled": true,
    "transfer_enabled": true,
    "transfer_to_wallet_enabled": true,
    "transfer_to_exchange_enabled": true,
    "manual_fiat_payin_enabled": false,
    "manual_fiat_payout_enabled": false,
    "sign": "฿",
    "qr_prefix": "bitcointestnet:",
    "crypto_payment_id_name": "",
    "crypto_explorer": "https://blockchain.info/tx/{tx}",
    "precision_transfer": "1",
    "delisted": false,
    "networks": [
      {
        "code": "test123",
        "network": "test",
        "protocol": "test123",
        "default": true,
        "is_ens_available": true,
        "payin_enabled": true,
        "payout_enabled": true,
        "precision_payout": "1",
        "payout_fee": "0.000000000000",
        "payout_is_payment_id": false,
        "payin_payment_id": false,
        "payin_confirmations": 3
      }
    ]
  },
  "ETH":
  {
    "full_name": "Ethereum TST",
    "crypto": true,
    "stable": true,
    "payin_enabled": true,
    "payout_enabled": true,
    "transfer_enabled": true,
    "transfer_to_wallet_enabled": true,
    "transfer_to_exchange_enabled": true,
    "manual_fiat_payin_enabled": false,
    "manual_fiat_payout_enabled": false,
    "sign": "E",
    "qr_prefix": "ethereum:",
    "crypto_payment_id_name": "",
    "crypto_explorer": "https://www.etherchain.org/tx/{tx}",
    "precision_transfer": "0.000000000001",
    "delisted": false,
    "networks": [
      {
        "code": "ETHTEST",
        "network_name": "ETHTEST",
        "network": "ETHTEST",
        "protocol": "",
        "default": true,
        "is_ens_available": true,
        "payin_enabled": true,
        "payout_enabled": true,
        "precision_payout": "0.000000000000000001",
        "payout_fee": "0.000000000000",
        "payout_is_payment_id": false,
        "payin_payment_id": false,
        "payin_confirmations": 2,
        "is_multichain": false
      }
    ]
  }
}

GET /api/3/public/currency

Returns the actual list of available currencies, tokens, etc.

You can optionally use a comma-separated list of currencies. If it is not provided, null or empty, the request returns all currencies.

Requires no API key Access Rights.

Parameters:

Name Type Description
currencies String Optional. Comma-separated list of currency codes.
preferred_network String Optional. Code of the default network for currencies.

Response:

Name Type Description
full_name String Currency full name (e.g., "Bitcoin").
crypto Boolean Flag indicating whether the currency is a cryptocurrency.
stable Boolean Flag indicating whether the currency is a stablecoin.
payin_enabled Boolean Flag indicating whether generating deposit addresses is allowed for the currency.
payout_enabled Boolean Flag indicating whether withdrawals are allowed for the currency.
transfer_enabled Boolean Flag indicating whether transfers between the bank and the exchange accounts are allowed for the network (may be disabled on maintenance).
transfer_to_wallet_enabled Boolean Flag indicating whether transfers to a wallet account are allowed.
transfer_to_exchange_enabled Boolean Flag indicating whether transfers to an exchange account are allowed.
manual_fiat_payin_enabled Boolean Flag indicating whether manual fiat deposits via bank transfer are allowed.
manual_fiat_payout_enabled Boolean Flag indicating whether manual fiat withdrawals via bank transfer are allowed.
sign String Currency sign.
crypto_payment_id_name String Optional. The name of an additional account identifier used for the protocol.
crypto_explorer String Optional. The link to the currency explorer with "{tx}" placeholder instead of a hash.
precision_transfer String The minimum amount of a transfer.
account_top_order Number Optional. The absolute position of the currency in the currency list.
qr_prefix String Optional. The QR prefix used for indication of the currency in a deposit address. Returned only for currencies where it is configured.
delisted Boolean Flag indicating whether the currency has been delisted.
networks []Network Networks that may host operations on the currency.

Network model consists of:

Name Type Description
code String Currency code.
network_name String Full network name.
network String Code of the currency of the hosting network.
is_ens_available Boolean Flag indicating whether the network supports ENS (Ethereum Name Service).
protocol String Optional. The standard or protocol underlying network operations or smart contracts.
If equals code, the currency is the network native currency.
If "TOKEN", the currency is a token build on top of this layer-2 network.
Example: "ERC20"
default Boolean Flag indicating whether the network is the default for the currency.
payin_enabled Boolean Flag indicating whether generating deposit addresses is allowed for the network.
payout_enabled Boolean Flag indicating whether withdrawals are allowed for the network.
precision_payout String The minimum amount of a withdrawal.
payout_fee String Optional. The minimal possible fee value constituted of the network fee charged by a blockchain and the maintenance fee charged by the exchange.
payout_is_payment_id Boolean Flag indicating whether providing additional information for withdrawals is needed.
payin_payment_id Boolean Flag indicating whether providing additional information for deposits is needed.
payin_confirmations Number The number of confirmation needed for a transaction to be accepted in the network.
address_regex String Optional. Regular expression to a deposit address.
payment_id_regex String Optional. Regular expression for a payment identifier.
low_processing_time Number Optional. The lowest processing time in seconds for a withdrawal.
high_processing_time Number Optional. The highest processing time in seconds for a withdrawal.
avg_processing_time Number Optional. The average processing time in seconds for a withdrawal.
crypto_payment_id_name String Optional. Transaction identifier, e.g., comment, message, memo, attachment, etc.
crypto_explorer String Optional. The link to the network explorer with "{tx}" placeholder instead of a hash.
contract_address String Optional. Token contract address.
is_multichain Boolean Flag indicating whether multichain is active for the network.
asset_id JSON Optional. A unique arbitrary object that identifies a coin. Object keys depend on the network/provider and values are strings.
payout_fee is a valid fee only if both network and maintenance fees fell below its minimal absolute values given the withdrawal amount.
Call GET /api/3/wallet/crypto/fee/estimate to see the exact value of fees based on the amount.

Get Currency

curl "https://api.hitbtc.com/api/3/public/currency/BTC"

Response:

{
  "full_name": "test",
  "crypto": true,
  "stable": true,
  "payin_enabled": true,
  "payout_enabled": true,
  "transfer_enabled": true,
  "transfer_to_wallet_enabled": true,
  "transfer_to_exchange_enabled": true,
  "manual_fiat_payin_enabled": false,
  "manual_fiat_payout_enabled": false,
  "sign": "฿",
  "qr_prefix": "bitcointestnet:",
  "crypto_payment_id_name": "",
  "crypto_explorer": "https://blockchain.info/tx/{tx}",
  "precision_transfer": "1",
  "delisted": false,
  "networks": [
    {
      "code": "test123",
      "network_name": "test123",
      "network": "test",
      "protocol": "test123",
      "default": true,
      "is_ens_available": true,
      "payin_enabled": true,
      "payout_enabled": true,
      "precision_payout": "1",
      "payout_fee": "0.000000000000",
      "payout_is_payment_id": false,
      "payin_payment_id": false,
      "payin_confirmations": 3,
      "is_multichain": false
    }
  ]
}

GET /api/3/public/currency/{currency}

Returns the data for a certain currency.

Requires no API key Access Rights.

Response:

Name Type Description
full_name String Currency full name (e.g., "Bitcoin").
crypto Boolean Flag indicating whether the currency is a cryptocurrency.
stable Boolean Flag indicating whether the currency is a stablecoin.
payin_enabled Boolean Flag indicating whether generating deposit addresses is allowed for the currency.
payout_enabled Boolean Flag indicating whether withdrawals are allowed for the currency.
transfer_enabled Boolean Flag indicating whether transfers between the bank and the exchange accounts are allowed for the network (may be disabled on maintenance).
transfer_to_wallet_enabled Boolean Flag indicating whether transfers to a wallet account are allowed.
transfer_to_exchange_enabled Boolean Flag indicating whether transfers to an exchange account are allowed.
manual_fiat_payin_enabled Boolean Flag indicating whether manual fiat deposits via bank transfer are allowed.
manual_fiat_payout_enabled Boolean Flag indicating whether manual fiat withdrawals via bank transfer are allowed.
sign String Currency sign.
crypto_payment_id_name String Optional. The name of an additional account identifier used for the protocol.
crypto_explorer String Optional. The link to the currency explorer with "{tx}" placeholder instead of a hash.
precision_transfer String The minimum amount of a transfer.
account_top_order Number Optional. The absolute position of the currency in the currency list.
qr_prefix String Optional. The QR prefix used for indication of the currency in a deposit address. Returned only for currencies where it is configured.
delisted Boolean Flag indicating whether the currency has been delisted.
networks []Network Networks that may host operations on the currency.

Response structure (including networks fields and optional/required behavior) is identical to GET /api/3/public/currency.

Symbols

Get Symbols

curl "https://api.hitbtc.com/api/3/public/symbol"

Response:

{
  "ETHBTC": {
    "type": "spot",
    "base_currency": "ETH",
    "quote_currency": "BTC",
    "status": "working",
    "quantity_increment": "0.001",
    "tick_size": "0.000001",
    "take_rate": "0.001",
    "make_rate": "-0.0001",
    "fee_currency": "BTC",
    "margin_trading": true,
    "max_initial_leverage": "10.00"
  }
}

GET /api/3/public/symbol

Returns the actual list of currency symbols (currency pairs) traded on exchange. The first listed currency of a symbol is called the base currency, and the second currency is called the quote currency.

The currency pair indicates how much of the quote currency is needed to purchase one unit of the base currency.

Read more

You can optionally use a comma-separated list of symbols. If it is not provided, null or empty, the request returns tickers for all symbols.

Requires no API key Access Rights.

All parameters are optional.

Parameters:

Name Type Description
symbols String Comma-separated list of symbol codes.

Response:

Name Type Description
type String Symbol type.
Possible values: spot, futures
contract_type String Contract type.
Possible values: perpetual, cash_settled
expiry DateTime or null Futures expiration date.
null for perpetual contracts.
underlying String Futures contract underlying asset.
base_currency String or null Name (code) of base currency, (e.g., "ETH"). For futures contracts is null.
quote_currency String Name (code) of quote currency.
status String Exchange status.
Possible values: working, suspended, clearing
quantity_increment String Symbol quantity should be divided by this value with no remainder.
tick_size String Symbol price should be divided by this value with no remainder.
take_rate String Default fee rate.
make_rate String Default fee rate for market making trades.
fee_currency String Currency in which fees are determined.
margin_trading Boolean Whether margin trading is available.
max_initial_leverage String Optional. Maximum leverage that the user can use for margin trading. Shown only if margin_trading is true.

Get Symbol

curl "https://api.hitbtc.com/api/3/public/symbol/ETHBTC"

Response:

{
  "type": "spot",
  "base_currency": "ETH",
  "quote_currency": "BTC",
  "status": "working",
  "quantity_increment": "0.0001",
  "tick_size": "0.000001",
  "take_rate": "0.002",
  "make_rate": "0.001",
  "fee_currency": "BTC",
  "margin_trading": true,
  "max_initial_leverage": "10.00"
}

GET /api/3/public/symbol/{symbol}

Returns the data for a certain symbol.

Requires no API key Access Rights.

Response:

Name Type Description
type String Symbol type.
Possible values: spot, futures
contract_type String Contract type.
Possible values: perpetual, cash_settled
expiry DateTime or null Futures expiration date.
null for perpetual contracts.
underlying String Futures contract underlying asset.
base_currency String or null Name (code) of base currency, (e.g., "ETH"). For futures contracts is null.
quote_currency String Name (code) of quote currency.
status String Exchange status.
Possible values: working, suspended, clearing
quantity_increment String Symbol quantity should be divided by this value with no remainder.
tick_size String Symbol price should be divided by this value with no remainder.
take_rate String Default fee rate.
make_rate String Default fee rate for market making trades.
fee_currency String Currency in which fees are determined.
margin_trading Boolean Whether margin trading is available.
max_initial_leverage String Optional. Maximum leverage that the user can use for margin trading. Shown only if margin_trading is true.

Tickers

Get Tickers

curl "https://api.hitbtc.com/api/3/public/ticker"

Response:

{
  "ETHBTC": {
    "ask": "0.050043",
    "bid": "0.050042",
    "last": "0.050042",
    "low": "0.047052",
    "high": "0.051679",
    "open": "0.047800",
    "volume": "36456.720",
    "volume_quote": "1782.625000",
    "timestamp": "2024-04-12T14:57:19.999Z"
  }
}

GET /api/3/public/ticker

Returns ticker information.

You can optionally use a comma-separated list of symbols. If it is not provided, null or empty, the request returns tickers for all symbols.

Requires no API key Access Rights.

Parameters:

Name Type Description
symbols String Optional. Comma-separated list of symbol codes.

Response:

Name Type Description
ask String or null Best ask price. Can return null if no data.
bid String or null Best bid price. Can return null if no data.
last String or null Last trade price. Can return null if no data.
low String The lowest trade price within 24 hours.
high String The highest trade price within 24 hours.
open String or null Last trade price 24 hours ago. Can return null if no data.
volume String Total trading amount within 24 hours in base currency.
volume_quote String Total trading amount within 24 hours in quote currency.
timestamp DateTime Last update or refresh ticker timestamp.

Get Ticker by Symbol

curl "https://api.hitbtc.com/api/3/public/ticker/ETHBTC"

Response:

{
  "ask": "0.020572",
  "bid": "0.020566",
  "last": "0.020574",
  "low": "0.020388",
  "high": "0.021084",
  "open": "0.020913",
  "volume": "138444.3666",
  "volume_quote": "2853.6874972480",
  "timestamp": "2024-04-02T17:52:36.731Z"
}

GET /api/3/public/ticker/{symbol}

Returns the ticker for a certain symbol.

Requires no API key Access Rights.

Response:

Name Type Description
ask String or null Best ask price. Can return null if no data.
bid String or null Best bid price. Can return null if no data.
last String or null Last trade price. Can return null if no data.
low String The lowest trade price within 24 hours.
high String The highest trade price within 24 hours.
open String or null Last trade price 24 hours ago. Can return null if no data.
volume String Total trading amount within 24 hours in base currency.
volume_quote String Total trading amount within 24 hours in quote currency.
timestamp DateTime Last update or refresh ticker timestamp.

Prices

Get Prices

curl "https://api.hitbtc.com/api/3/public/price/rate?from=ETH&to=BTC"

Response:

{
  "ETH":{
    "currency": "BTC",
    "price": "0.021084",
    "timestamp": "2024-04-02T17:52:36.731Z"
  }
}

GET /api/3/public/price/rate

Returns the mean of "best" bid price and "best" ask price in the order book.

If there is no "best" bid of ask price, the last price is returned.
If provided currencies do not match any existing symbol, the rate for intermediate pairs are multiplied of inverted depending on the direction of exchange in these pairs.
If there is no rate, an empty object is returned.

Requires no API key Access Rights.

Parameters:

Name Type Description
from String Source currency code.
to String Target currency code.

Response:

Name Type Description
currency String Quote currency code.
price String Quotation price.
timestamp DateTime Last update or refresh price timestamp.

Get Prices History

curl "https://api.hitbtc.com/api/3/public/price/history?from=ETH&to=BTC"

Response:

{
  "ETH": {
    "currency": "BTC",
    "history": [
      {
        "timestamp": "2024-07-01T20:00:00.000Z",
        "open": "0.063420",
        "close": "0.063767",
        "min": "0.063403",
        "max": "0.063782"
      }
    ]
  }
}

GET /api/3/public/price/history

Returns quotation prices history.

Requires no API key Access Rights.

Parameters:

Name Type Description
from String Source currency code.
to String Target currency code.
until DateTime Optional. Interval end value.
since DateTime Optional. Interval initial value.
limit Number Optional
Default value: 1
Accepted values: 1 – 1000
period String Optional. Accepted values: M1 (one minute), M3, M5, M15, M30, H1 (one hour), H4, D1 (one day), D7, 1M (one month)
Default value: M30 (30 minutes)
sort String Optional. Sort direction.
Accepted values: ASC, DESC
Default value: DESC

Response:

Name Type Description
currency String Quote currency code.
history History Quotation price history entry.

History model consists of:

Name Type Description
timestamp DateTime Last update or refresh price timestamp.
open String Open price.
close String Closing price.
min String The lowest price for the period.
max String The highest price for the period.

Get Ticker Last Prices

curl "https://api.hitbtc.com/api/3/public/price/ticker"

Response:

{
  "ETHBTC": {
    "price": "0.050042",
    "timestamp": "2024-04-12T14:57:19.999Z"
  }
}

GET /api/3/public/price/ticker

Returns tickers' last prices for all symbols.

You can optionally use a comma-separated list of symbols. If it is not provided, null or empty, the request returns tickers for all symbols.

Requires no API key Access Rights.

Parameters:

Name Type Description
symbols String Optional. Comma-separated list of symbol codes.

Response:

Name Type Description
price String Ticker last price.
timestamp DateTime Last update or refresh ticker timestamp.

Get Ticker Last Price by Symbol

curl "https://api.hitbtc.com/api/3/public/price/ticker/ETHBTC"

Response:

{
  "price": "0.021084",
  "timestamp": "2024-04-02T17:52:36.731Z"
}

GET /api/3/public/price/ticker/{symbol}

Returns the ticker last price for a certain symbol.

Requires no API key Access Rights.

Response:

Name Type Description
price String Ticker last price.
timestamp DateTime Last update or refresh ticker timestamp.

Trades

Get Trades

curl "https://api.hitbtc.com/api/3/public/trades"

Response:

{
  "BTCUSDT":[
    {
      "id":3494,
      "price":"9793.94",
      "qty":"0.21469",
      "side":"sell",
      "timestamp":"2024-04-24T12:54:41.972Z"
    }
  ],
  "ETHBTC":[
    {
      "id":3495,
      "price":"0.027668",
      "qty":"0.069",
      "side":"buy",
      "timestamp":"2024-04-24T12:54:32.843Z"
    }
  ]
}

GET /api/3/public/trades

Returns trades information for all or multiple symbols.

You can optionally use a comma-separated list of symbols. If it is not provided, null or empty, the request returns tickers for all symbols.

Requires no API key Access Rights.

All parameters are optional.

Parameters:

Name Type Description
symbols String Comma-separated list of symbol codes.
by String Filter type.
Accepted values: id, timestamp
Default value: timestamp
sort String Sort direction.
Accepted values: ASC, DESC
Default value: DESC
from DateTime or Number Interval initial value.
If sorting by timestamp is used, then DateTime; otherwise — Number.
till DateTime or Number Interval end value.
If sorting by timestamp is used, then DateTime; otherwise — Number.
limit Number Default value: 10
Accepted values: 1 – 1000

Response:

Name Type Description
id Number Trade identifier.
price String Trade price.
qty String Trade quantity.
side String Trade side.
Accepted values: sell, buy
timestamp DateTime Trade timestamp.

Get Trades by Symbol

curl "https://api.hitbtc.com/api/3/public/trades/ETHBTC?sort=DESC"

Response:

[
  {
    "id": 9533117,
    "price": "0.046001",
    "qty": "0.220",
    "side": "sell",
    "timestamp": "2024-04-14T12:18:40.426Z"
  },
  {
    "id": 9533116,
    "price": "0.046002",
    "qty": "0.022",
    "side": "buy",
    "timestamp": "2024-04-14T11:56:37.027Z"
  }
]

GET /api/3/public/trades/{symbol}

Returns trades information for a certain symbol.

Requires no API key Access Rights.

All parameters are optional.

Parameters:

Name Type Description
by String Filter type.
Accepted values: id, timestamp
Default value: timestamp
sort String Sort direction.
Accepted values: ASC, DESC
Default value: DESC
from DateTime or Number Optional. Interval initial value.
If sorting by timestamp is used, then DateTime; otherwise — Number.
till DateTime or Number Optional. Interval end value.
If sorting by timestamp is used, then DateTime; otherwise — Number.
limit Number Default value: 100
Accepted values: 1 – 1000
offset Number Default value: 0
Accepted values: 0 – 100000

Response:

Name Type Description
id Number Trade identifier.
price String Trade price.
qty String Trade quantity.
side String Trade side.
Possible values: sell, buy
timestamp DateTime Trade timestamp.

Order Books

Get Order Books

curl "https://api.hitbtc.com/api/3/public/orderbook"

Response:

{
  "BTCUSDT": {
    "timestamp": "2024-04-11T11:18:03.857366871Z",
    "ask": [
      [
        "9777.51",                       // Price
        "4.50579"                        // Amount
      ],
      [
        "9777.52",
        "5.79832"
      ]
    ],
    "bid": [
      [
        "9777.5",
        "0.00002"
      ],
      [
        "9776.26",
        "0.0001"
      ]
    ]
  },
  "ETHBTC": {
    "timestamp": "2024-04-11T11:18:03.790858502Z",
    "ask": [
      [
        "0.022626",
        "0.0057"
      ],
      [
        "0.022628",
        "1.4259"
      ]
    ],
    "bid": [
      [
        "0.022624",
        "0.5748"
      ],
      [
        "0.022623",
        "26.5"
      ]
    ]
  }
}

GET /api/3/public/orderbook

An Order Book is a list of buy and sell orders for a specific symbol, structured by price level.

You can optionally use a comma-separated list of symbols. If it is not provided, null or empty, the request returns tickers for all symbols.

Requires no API key Access Rights.

Parameters:

Name Type Description
depth Number Optional. Order Book depth.
Default value: 10
Set to 0 to view the full Order Book.
symbols String Optional. Comma-separated list of symbol codes.

Response:

Name Type Description
timestamp DateTime Publication timestamp.
ask []String Ask side array of levels.
bid []String Bid side array of levels.

Get Order Book by Symbol

curl "https://api.hitbtc.com/api/3/public/orderbook/ETHBTC?volume=0.5"

Response:

{
  "timestamp": "2024-04-11T11:30:38.597950917Z",
  "ask": [
     [
        "9779.68",                       // Price
        "2.497"                          // Quantity
      ]
    ],
  "bid": [
    [
      "9779.67",
      "0.03719"
    ],
    [
      "9779.29",
      "0.171"
    ],
    [
      "9779.27",
      "0.171"
    ],
    [
      "9779.21",
      "0.171"
    ]
  ]
}

GET /api/3/public/orderbook/{symbol}

The request returns an Order Book for a certain symbol.

Requires no API key Access Rights.

Parameters:

Name Type Description
depth Number Optional. Order Book depth.
Default value: 100
Set to 0 to view the full Order Book.
volume Number Optional. Desired volume for market depth search.

Please note that if the volume is specified, the depth will be ignored.

Response:

Name Type Description
timestamp DateTime Publication timestamp.
ask []String Ask side array of levels.
bid []String Bid side array of levels.

Candles

Get Candles

curl "https://api.hitbtc.com/api/3/public/candles"

Response:

{
  "BTCUSDT":[
    {
      "timestamp": "2024-07-01T20:00:00.000Z",
      "open": "33079.93",
      "close": "33236.53",
      "min": "33079.93",
      "max": "33295.73",
      "volume": "146.86223",
      "volume_quote": "4877838.3025063"
    }
  ],
  "ETHBTC":[
    {
      "timestamp": "2024-07-01T20:00:00.000Z",
      "open": "0.063420",
      "close": "0.063767",
      "min": "0.063403",
      "max": "0.063782",
      "volume": "866.6776",
      "volume_quote": "55.2132903904"
    }
  ]
}

GET /api/3/public/candles

Candles are used for the representation of a specific symbol as an OHLC chart.

You can optionally use a comma-separated list of symbols. If it is not provided, null or empty, the request returns tickers for all symbols.

Requires no API key Access Rights.

All parameters are optional.

Parameters:

Name Type Description
symbols String Comma-separated list of symbol codes.
sort String Sort direction.
Accepted values: ASC, DESC
Default value: DESC
period String Accepted values: M1 (one minute), M3, M5, M15, M30, H1 (one hour), H4, D1 (one day), D7, 1M (one month)
Default value: M30 (30 minutes)
from DateTime Interval initial value.
till DateTime Interval end value.
limit Number Default value: 10
Accepted values: 1 – 1000

Response:

Name Type Description
timestamp DateTime Candle timestamp.
open String Open price.
close String Closing price.
min String The lowest price for the period.
max String The highest price for the period.
volume String Volume in base currency.
volume_quote String Volume in quote currency.
The result contains candles with non-zero volume only (no trades — no candles).

Get Candles by Symbol

curl "https://api.hitbtc.com/api/3/public/candles/ETHBTC"

Response:

[
  {
    "timestamp": "2024-04-20T20:00:00.000Z",
    "open": "0.050459",
    "close": "0.050087",
    "min": "0.050000",
    "max": "0.050511",
    "volume": "1326.628",
    "volume_quote": "66.555987736"
  },
  {
    "timestamp": "2024-04-20T20:30:00.000Z",
    "open": "0.050108",
    "close": "0.050139",
    "min": "0.050068",
    "max": "0.050223",
    "volume": "87.515",
    "volume_quote": "4.386062831"
  }
]

GET /api/3/public/candles/{symbol}

Returns candles for a certain symbol.

Requires no API key Access Rights.

All parameters are optional.

Parameters:

Name Type Description
sort String Sort direction.
Accepted values: ASC, DESC
Default value: DESC
period String Accepted values: M1 (one minute), M3, M5, M15, M30, H1 (one hour), H4, D1 (one day), D7, 1M (one month)
Default value: M30 (30 minutes)
from DateTime Interval initial value.
till DateTime Interval end value.
limit Number Default value: 100
Accepted values: 1 – 1000
offset Number Default value: 0
Accepted values: 0 – 100000

Response:

Name Type Description
timestamp DateTime Candle timestamp.
open String Open price.
close String Closing price.
min String The lowest price for the period.
max String The highest price for the period.
volume String Volume in base currency.
volume_quote String Volume in quote currency.
The result contains candles with non-zero volume only (no trades — no candles).

Get Converted Candles

curl "https://api.hitbtc.com/api/3/public/converted/candles?target_currency=USDT"

Response:

{
  "target_currency": "USDT",
  "data": {
    "BTCUSDT": [
      {
        "timestamp": "2024-02-01T10:30:00.000Z",
        "open": "42265.17",
        "close": "42196.10",
        "min": "42182.49",
        "max": "42269.15",
        "volume": "60.88187",
        "volume_quote": "2569178.2573316"
      }
    ],
    "ETHBTC": [
      {
        "timestamp": "2024-02-01T10:30:00.000Z",
        "open": "2270.91293888",
        "close": "2268.00140384",
        "min": "2267.70603072",
        "max": "2271.50368512",
        "volume": "13.6669",
        "volume_quote": "31032.101773456736"
      }
    ]
  }
}

GET /api/3/public/converted/candles

Returns OHLCV data regarding the last price converted to the target currency for all symbols.

Candles are used for the representation of a specific symbol as an OHLC chart.

Requires no API key Access Rights.

You can optionally use a comma-separated list of symbols. If it is not provided, null or empty, the request returns candles for all symbols.
This call produces the same output as GET /api/3/public/converted/candles except all values in quote currency are converted to the target currency.
Conversion from the symbol quote currency to the target currency is the mean of the "best" bid price and the "best" ask price in the order book. If there is no "best" bid of ask price, the last price is returned.

Parameters:

Name Type Description
target_currency String Target currency for conversion.
symbols String Comma-separated list of symbol codes.
sort String Sort direction.
Accepted values: ASC, DESC
Default value: DESC
period String Accepted values: M1 (one minute), M3, M5, M15, M30, H1 (one hour), H4, D1 (one day), D7, 1M (one month)
Default value: M30 (30 minutes)
from DateTime Interval initial value.
till DateTime Interval end value.
limit Number Default value: 10
Accepted values: 1 – 1000

Response:

Name Type Description
target_currency String Target currency for conversion.
data Map Candles converted to the target currency.
> []JSON Symbol code.
>> timestamp DateTime Candle timestamp.
>> open Number Open price.
>> close Number Closing price.
>> min Number The lowest price for the period.
>> max Number The highest price for the period.
>> volume Number Volume in base currency.
>> volume_quote Number Volume in quote currency.
The result contains candles with non-zero volume only (no trades — no candles).

Get Converted Candles by Symbol

curl "https://api.hitbtc.com/api/3/public/converted/candles/ETHBTC?target_currency=USDT"

Response:

{
  "target_currency": "USDT",
  "data": [
    {
      "timestamp": "2024-02-01T10:30:00.000Z",
      "open": "2270.614518070",
      "close": "2267.450221945",
      "min": "2267.365840715",
      "max": "2271.205186680",
      "volume": "13.7525",
      "volume_quote": "31222.1126879271435"
    }
  ]
}

GET /api/3/public/converted/candles/{symbol}

Returns OHLCV data regarding the last price converted to the target currency for a symbol.

You can optionally use a comma-separated list of symbols. If it is not provided, null or empty, the request returns candles for all symbols.
This call produces the same output as GET /api/3/public/converted/candles except all values in quote currency are converted to the target currency.
Conversion from the symbol quote currency to the target currency is the mean of "best" bid price and "best" ask price in the order book. If there is no "best" bid of ask price, the last price is returned.

All parameters are optional.

Parameters:

Name Type Description
sort String Sort direction.
Accepted values: ASC, DESC
Default value: DESC
period String Accepted values: M1 (one minute), M3, M5, M15, M30, H1 (one hour), H4, D1 (one day), D7, 1M (one month)
Default value: M30 (30 minutes)
from DateTime Interval initial value.
till DateTime Interval end value.
limit Number Default value: 100
Accepted values: 1 – 1000
offset Number Default value: 0
Accepted values: 0 – 100000

Response:

Name Type Description
target_currency String Target currency for conversion.
data []JSON Candles converted to the target currency.
> timestamp DateTime Candle timestamp.
> open Number Open price.
> close Number Closing price.
> min Number The lowest price for the period.
> max Number The highest price for the period.
> volume Number Volume in base currency.
> volume_quote Number Volume in quote currency.
The result contains candles with non-zero volume only (no trades — no candles).

Futures Info

Get Futures Information

curl "https://api.hitbtc.com/api/3/public/futures/info"

Response:

{
  "UFO-1217": {
    "contract_type": "cash_settled",
    "mark_price": "1.21838",
    "index_price": "1.21838",
    "open_interest": "0",
    "indicative_settlement_price": "1.22421",
    "expiry": "2024-12-17T14:00:00.000Z",
    "timestamp": "2024-12-17T14:00:01.062Z"
  },
  "BTCUSDT_PERP": {
    "contract_type": "perpetual",
    "mark_price": "30897.68",
    "index_price": "30895.29",
    "funding_rate": "0.0001",
    "open_interest": "93.7128",
    "next_funding_time": "2024-07-21T16:00:00.000Z",
    "indicative_funding_rate": "0.0001",
    "premium_index": "0.000047541807127312",
    "avg_premium_index": "0.000087063368020112",
    "interest_rate": "0.0001",
    "timestamp": "2024-07-21T09:48:37.235Z"
  },
  "EOSETH_PERP": {
    "contract_type": "perpetual",
    "mark_price":"0.0020600",
    "index_price":"0.0020600",
    "funding_rate":"0.0001",
    "open_interest":"60.6580",
    "next_funding_time":"2024-04-25T16:00:00.000Z",
    "indicative_funding_rate":"0.0001",
    "premium_index":"0.1045547",
    "avg_premium_index":"0.1004467",
    "interest_rate": "0.0001",
    "timestamp":"2024-04-25T14:43:20.079Z"
  }
}

GET /api/3/public/futures/info

Returns futures information for all or multiple contracts.

Requires no API key Access Rights.

Parameters:

Name Type Description
symbols String Optional. Comma-separated list of contract codes.

Response:

Name Type Description
contract_type String Contract type.
Possible values: perpetual, cash_settled
mark_price String Recent asset price adjusted by the value of fair basis.
index_price String Average underlying asset price.
funding_rate String Optional. Percent of the contract's mark value paid in the previous funding period. Returned only if contract_type is perpetual.
open_interest String Total quantity of traded futures contracts.
next_funding_time DateTime Optional. Timestamp of the next funding. Returned only if contract_type is perpetual.
indicative_funding_rate String Optional. Estimated percent of the contract's mark value to be paid after the end of the current funding period, calculated at the moment. Returned only if contract_type is perpetual.
premium_index String Optional. Time-weighted average over premium indexes from the previous funding to the moment. Used during calculation of indicative_funding_rate. Returned only if contract_type is perpetual.
avg_premium_index String Optional. Time-weighted average over premium indexes for the previous funding period. Used during calculation of funding_rate for adjusting it to the deviation of contract market price from the mark price. Returned only if contract_type is perpetual.
interest_rate String Optional. Contract interest rate for one funding period.
indicative_settlement_price String Optional. Expected price of closing position on a cash settled contract. Calculated during the last 30 minutes prior to contract expiration — until that, equals to index_price. Returned only if contract_type is cash_settled.
expiry DateTime Optional. Contract expiration date. Returned only if contract_type is cash_settled.
timestamp DateTime Request timestamp.

Get Futures Information for Contract

curl "https://api.hitbtc.com/api/3/public/futures/info/BTCUSDT_PERP"

Response:

{
  "BTCUSDT_PERP": {
    "contract_type": "perpetual",
    "mark_price": "30897.68",
    "index_price": "30895.29",
    "funding_rate": "0.0001",
    "open_interest": "93.7128",
    "next_funding_time": "2024-07-21T16:00:00.000Z",
    "indicative_funding_rate": "0.0001",
    "premium_index": "0.000047541807127312",
    "avg_premium_index": "0.000087063368020112",
    "interest_rate": "0.0001",
    "timestamp": "2024-07-21T09:48:37.235Z"
  }
}

GET /api/3/public/futures/info/{symbol}

Returns futures information for a specified contract.

Requires no API key Access Rights.

Response:

Name Type Description
contract_type String Contract type.
Possible values: perpetual, cash_settled
mark_price String Recent asset price adjusted by the value of fair basis.
index_price String Average underlying asset price.
funding_rate String Optional. Percentage of contract mark value paid after the end of current funding interval. Returned only if contract_type is perpetual.
open_interest String Total quantity of traded futures contracts.
next_funding_time DateTime Optional. Timestamp of the next funding. Returned only if contract_type is perpetual.
indicative_funding_rate String Optional. Estimated percent of the contract's mark value to be paid after the end of the current funding period, calculated at the moment. Returned only if contract_type is perpetual.
premium_index String Optional. Time-weighted average over premium indexes from the previous funding to the moment. Used during calculation of indicative_funding_rate. Returned only if contract_type is perpetual.
avg_premium_index String Optional. Time-weighted average over premium indexes for the previous funding period. Used during calculation of funding_rate for adjusting it to the deviation of contract market price from the mark price. Returned only if contract_type is perpetual.
interest_rate String Optional. Contract interest rate for one funding period.
indicative_settlement_price String Optional. Expected price of closing position on a cash settled contract. Calculated during the last 30 minutes prior to contract expiration — until that, equals to index_price. Returned only if contract_type is cash_settled.
expiry DateTime Optional. Contract expiration date. Returned only if contract_type is cash_settled.
timestamp DateTime Request timestamp.

Funding History

Get Funding History

curl "https://api.hitbtc.com/api/3/public/futures/history/funding"

Response:

{
  "BTCUSDT_PERP": [
    {
      "timestamp": "2024-07-29T16:00:00.271Z",
      "funding_rate": "0.0001",
      "avg_premium_index": "0.000061858585213222",
      "next_funding_time": "2024-07-30T00:00:00.000Z",
      "interest_rate": "0.0001"
    },
    {
      "timestamp": "2024-07-29T08:00:00.506Z",
      "funding_rate": "0.0001",
      "avg_premium_index": "0.000064275104721498",
      "next_funding_time": "2024-07-29T16:00:00.000Z",
      "interest_rate": "0.0001"
    },
    {
      "timestamp": "2024-07-29T00:00:00.233Z",
      "funding_rate": "0.0001",
      "avg_premium_index": "0.000025719039726718",
      "next_funding_time": "2024-07-29T08:00:00.000Z",
      "interest_rate": "0.0001"
    }
  ]
}

GET /api/3/public/futures/history/funding

Returns funding history for specified perpetual contracts or all of those.

Requires no API key Access Rights.

All parameters are optional.

Parameters:

Name Type Description
symbols String Comma-separated list of symbol codes.
sort String Sort direction.
Accepted values: ASC, DESC
Default value: DESC
from DateTime Interval initial value.
till DateTime Interval end value.
limit Number Default value: 10
Accepted values: 1 – 1000
offset Number Default value: 0
Accepted values: 0 – 100000

Response:

Name Type Description
timestamp DateTime Request timestamp.
funding_rate String Percentage of contract mark value paid after the end of current funding interval.
avg_premium_index String Time-weighted average over premium indexes for the previous funding period. Used during calculation of funding_rate for adjusting it to the deviation of contract market price from the mark price.
next_funding_time DateTime Timestamp of the next funding.
interest_rate String Contract interest rate for one funding period.

Get Funding History for Contract

curl "https://api.hitbtc.com/api/3/public/futures/history/funding/BTCUSDT_PERP"

Response:

  [
    {
      "timestamp": "2024-07-29T16:00:00.271Z",
      "funding_rate": "0.0001",
      "avg_premium_index": "0.000061858585213222",
      "next_funding_time": "2024-07-30T00:00:00.000Z",
      "interest_rate": "0.0001"
    },
    {
      "timestamp": "2024-07-29T08:00:00.506Z",
      "funding_rate": "0.0001",
      "avg_premium_index": "0.000064275104721498",
      "next_funding_time": "2024-07-29T16:00:00.000Z",
      "interest_rate": "0.0001"
    }
  ]

GET /api/3/public/futures/history/funding/{symbol}

Returns funding history for a specified perpetual contract.

Requires no API key Access Rights.

All parameters are optional.

Parameters:

Name Type Description
sort String Sort direction.
Accepted values: ASC, DESC
Default value: DESC
from DateTime Interval initial value.
till DateTime Interval end value.
limit Number Default value: 100
Accepted values: 1 – 1000
offset Number Default value: 0
Accepted values: 0 – 100000

Response:

Name Type Description
timestamp DateTime Request timestamp.
funding_rate String Percent of the contract's mark value paid in the previous funding period.
avg_premium_index String Time-weighted average over premium indexes for the previous funding period. Used during calculation of funding_rate for adjusting it to the deviation of contract market price from the mark price.
next_funding_time DateTime Timestamp of the next funding.
interest_rate String Contract interest rate for one funding period.

Futures Index Price Candles

Get Index Price Candles

curl "https://api.hitbtc.com/api/3/public/futures/candles/index_price"

Response:

{
  "BTCUSDT_PERP": [
    {
      "timestamp": "2024-07-08T07:30:00.000Z",
      "open": "32414.58",
      "close": "32414.58",
      "min": "32414.58",
      "max": "32414.58"
    },
    {
      "timestamp": "2024-07-07T18:00:00.000Z",
      "open": "34748.31",
      "close": "34748.31",
      "min": "34748.31",
      "max": "34748.31"
    },
    {
      "timestamp": "2024-07-07T12:30:00.000Z",
      "open": "34777.96",
      "close": "34777.96",
      "min": "34777.96",
      "max": "34777.96"
    }
  ]
}

GET /api/3/public/futures/candles/index_price

Returns index price candles for all contracts.

Requires no API key Access Rights.

All parameters are optional.

Parameters:

Name Type Description
symbols String Comma-separated list of contract codes.
sort String Sort direction.
Accepted values: ASC, DESC
Default value: DESC
period String Accepted values: M1 (one minute), M3, M5, M15, M30, H1 (one hour), H4, D1 (one day), D7, 1M (one month)
Default value: M30 (30 minutes)
from DateTime Interval initial value.
till DateTime Interval end value.
limit Number Default value: 10
Accepted values: 1 – 1000

Response:

Name Type Description
timestamp DateTime Candle timestamp.
open String Open index price.
close String Closing index price.
min String The lowest index price for the period.
max String The highest index price for the period.

Get Index Price Candles by Contract

curl "https://api.hitbtc.com/api/3/public/futures/candles/index_price/BTCUSDT_PERP"

Response:

[
  {
    "timestamp": "2024-07-08T07:30:00.000Z",
    "open": "32414.58",
    "close": "32414.58",
    "min": "32414.58",
    "max": "32414.58"
  },
  {
    "timestamp": "2024-07-07T18:00:00.000Z",
    "open": "34748.31",
    "close": "34748.31",
    "min": "34748.31",
    "max": "34748.31"
  },
  {
    "timestamp": "2024-07-07T12:30:00.000Z",
    "open": "34777.96",
    "close": "34777.96",
    "min": "34777.96",
    "max": "34777.96"
  }
]

GET /api/3/public/futures/candles/index_price/{symbol}

Returns index price candles for a certain contract.

Requires no API key Access Rights.

All parameters are optional.

Parameters:

Name Type Description
period String Accepted values: M1 (one minute), M3, M5, M15, M30, H1 (one hour), H4, D1 (one day), D7, 1M (one month)
Default value: M30 (30 minutes)
sort String Sort direction.
Accepted values: ASC, DESC
Default value: DESC
from DateTime Interval initial value.
till DateTime Interval end value.
limit Number Default value: 100
Accepted values: 1 – 1000
offset Number Default value: 0
Accepted values: 0 – 100000

Response:

Name Type Description
timestamp DateTime Candle timestamp.
open String Open index price.
close String Closing index price.
min String The lowest index price for the period.
max String The highest index price for the period.

Futures Mark Price Candles

Get Mark Price Candles

curl "https://api.hitbtc.com/api/3/public/futures/candles/mark_price"

Response:

{
  "BTCUSDT_PERP": [
    {
      "timestamp": "2024-07-08T07:30:00.000Z",
      "open": "32414.58",
      "close": "32414.58",
      "min": "32414.58",
      "max": "32414.58"
    },
    {
      "timestamp": "2024-07-07T18:00:00.000Z",
      "open": "34748.31",
      "close": "34748.31",
      "min": "34748.31",
      "max": "34748.31"
    },
    {
      "timestamp": "2024-07-07T12:30:00.000Z",
      "open": "34777.96",
      "close": "34777.96",
      "min": "34777.96",
      "max": "34777.96"
    }
  ]
}

GET /api/3/public/futures/candles/mark_price

Returns mark price candles for all contracts.

Requires no API key Access Rights.

All parameters are optional.

Parameters:

Name Type Description
period String Accepted values: M1 (one minute), M3, M5, M15, M30, H1 (one hour), H4, D1 (one day), D7, 1M (one month)
Default value: M30 (30 minutes)
sort String Sort direction.
Accepted values: ASC, DESC
Default value: DESC
from DateTime Interval initial value.
till DateTime Interval end value.
limit Number Limit to candles.
Default value: 10
Maximum value: 1000

Response:

Name Type Description
timestamp DateTime Candle timestamp.
open String Open mark price.
close String Closing mark price.
min String The lowest mark price for the period.
max String The highest mark price for the period.

Get Mark Price Candles by Contract

curl "https://api.hitbtc.com/api/3/public/futures/candles/mark_price/BTCUSDT_PERP"

Response:

[
  {
    "timestamp": "2024-07-08T07:30:00.000Z",
    "open": "32414.58",
    "close": "32414.58",
    "min": "32414.58",
    "max": "32414.58"
  },
  {
    "timestamp": "2024-07-07T18:00:00.000Z",
    "open": "34748.31",
    "close": "34748.31",
    "min": "34748.31",
    "max": "34748.31"
  },
  {
    "timestamp": "2024-07-07T12:30:00.000Z",
    "open": "34777.96",
    "close": "34777.96",
    "min": "34777.96",
    "max": "34777.96"
  }
]

GET /api/3/public/futures/candles/mark_price/{symbol}

Returns mark price candles for a certain contract.

Requires no API key Access Rights.

All parameters are optional.

Parameters:

Name Type Description
period String Accepted values: M1 (one minute), M3, M5, M15, M30, H1 (one hour), H4, D1 (one day), D7, 1M (one month)
Default value: M30 (30 minutes)
sort String Sort direction.
Accepted values: ASC, DESC
Default value: DESC
from DateTime Interval initial value.
till DateTime Interval end value.
limit Number Default value: 100
Accepted values: 1 – 1000
offset Number Default value: 0
Accepted values: 0 – 100000

Response:

Name Type Description
timestamp DateTime Candle timestamp.
open String Open mark price.
close String Closing mark price.
min String The lowest mark price for the period.
max String The highest mark price for the period.

Futures Premium Index Candles

Get Premium Index Candles

curl "https://api.hitbtc.com/api/3/public/futures/candles/premium_index"

Response:

{
  "BTCUSDT_PERP": [
    {
      "timestamp": "2024-07-08T23:00:00.000Z",
      "open": "0.0001",
      "close": "-0.000204666639856002",
      "min": "-0.000390287528832163",
      "max": "0.000191382142641392"
    },
    {
      "timestamp": "2024-07-08T22:30:00.000Z",
      "open": "-0.000057633026633848",
      "close": "0.00006436921844495",
      "min": "-0.00060179788527768",
      "max": "0.0001"
    },
    {
      "timestamp": "2024-07-08T22:00:00.000Z",
      "open": "0.0001",
      "close": "-0.000205510656144068",
      "min": "-0.000604732863348008",
      "max": "0.0001"
    }
  ]
}

GET /api/3/public/futures/candles/premium_index

Returns premium index candles for all contracts.

Requires no API key Access Rights.

All parameters are optional.

Parameters:

Name Type Description
symbols String Comma-separated list of contract codes.
sort String Sort direction.
Accepted values: ASC, DESC
Default value: DESC
period String Accepted values: M1 (one minute), M3, M5, M15, M30, H1 (one hour), H4, D1 (one day), D7, 1M (one month)
Default value: M30 (30 minutes)
from DateTime Interval initial value.
till DateTime Interval end value.
limit Number Default value: 10
Accepted values: 1 – 1000

Response:

Name Type Description
timestamp DateTime Candle timestamp.
open String Open premium index.
close String Closing premium index.
min String The lowest premium index for the period.
max String The highest premium index for the period.

Get Premium Index Candles by Contract

curl "https://api.hitbtc.com/api/3/public/futures/candles/premium_index/BTCUSDT_PERP"

Response:

[
  {
    "timestamp": "2024-07-08T23:00:00.000Z",
    "open": "0.0001",
    "close": "-0.000204666639856002",
    "min": "-0.000390287528832163",
    "max": "0.000191382142641392"
  },
  {
    "timestamp": "2024-07-08T22:30:00.000Z",
    "open": "-0.000057633026633848",
    "close": "0.00006436921844495",
    "min": "-0.00060179788527768",
    "max": "0.0001"
  },
  {
    "timestamp": "2024-07-08T22:00:00.000Z",
    "open": "0.0001",
    "close": "-0.000205510656144068",
    "min": "-0.000604732863348008",
    "max": "0.0001"
  }
]

GET /api/3/public/futures/candles/premium_index/{symbol}

Returns premium index candles for a certain contract.

Requires no API key Access Rights.

All parameters are optional.

Parameters:

Name Type Description
sort String Sort direction.
Accepted values: ASC, DESC
Default value: DESC
period String Accepted values: M1 (one minute), M3, M5, M15, M30, H1 (one hour), H4, D1 (one day), D7, 1M (one month)
Default value: M30 (30 minutes)
from DateTime Interval initial value.
till DateTime Interval end value.
limit Number Default value: 100
Accepted values: 1 – 1000
offset Number Default value: 0
Accepted values: 0 – 100000

Response:

Name Type Description
timestamp DateTime Candle timestamp.
open String Open premium index.
close String Closing premium index.
min String The lowest premium index for the period.
max String The highest premium index for the period.

Futures Open Interest Candles

Get Open Interest Candles

curl "https://api.hitbtc.com/api/3/public/futures/candles/open_interest"

Response:

{
  "BTCUSDT_PERP": [
    {
      "timestamp": "2024-07-22T16:30:00.000Z",
      "open": "1.06523",
      "close": "1.06523",
      "min": "1.06523",
      "max": "1.06523"
    },
    {
      "timestamp": "2024-07-22T16:00:00.000Z",
      "open": "1.06523",
      "close": "1.06523",
      "min": "1.06523",
      "max": "1.06523"
    },
    {
      "timestamp": "2024-07-22T15:30:00.000Z",
      "open": "1.06523",
      "close": "1.06523",
      "min": "1.06523",
      "max": "1.06523"
    }
  ]
}

GET /api/3/public/futures/candles/open_interest

Returns open interest candles for all contracts.

Requires no API key Access Rights.

All parameters are optional.

Parameters:

Name Type Description
symbols String Comma-separated list of contract codes.
sort String Sort direction.
Accepted values: ASC, DESC
Default value: DESC
period String Accepted values: M1 (one minute), M3, M5, M15, M30, H1 (one hour), H4, D1 (one day), D7, 1M (one month)
Default value: M30 (30 minutes)
from DateTime Interval initial value.
till DateTime Interval end value.
limit Number Default value: 10
Accepted values: 1 – 1000

Response:

Name Type Description
timestamp DateTime Candle timestamp.
open String Opening value.
close String Closing value.
min String The lowest open interest for the period.
max String The highest open interest for the period.

Get Open Interest Candles by Contract

curl "https://api.hitbtc.com/api/3/public/futures/candles/open_interest/BTCUSDT_PERP"

Response:

[
  {
    "timestamp": "2024-07-22T16:30:00.000Z",
    "open": "1.06523",
    "close": "1.06523",
    "min": "1.06523",
    "max": "1.06523"
  },
  {
    "timestamp": "2024-07-22T16:00:00.000Z",
    "open": "1.06523",
    "close": "1.06523",
    "min": "1.06523",
    "max": "1.06523"
  },
  {
    "timestamp": "2024-07-22T15:30:00.000Z",
    "open": "1.06523",
    "close": "1.06523",
    "min": "1.06523",
    "max": "1.06523"
  }
]

GET /api/3/public/futures/candles/open_interest/{symbol}

Returns open interest candles for a certain contract.

Requires no API key Access Rights.

All parameters are optional.

Parameters:

Name Type Description
sort String Sort direction.
Accepted values: ASC, DESC
Default value: DESC
period String Accepted values: M1 (one minute), M3, M5, M15, M30, H1 (one hour), H4, D1 (one day), D7, 1M (one month)
Default value: M30 (30 minutes)
from DateTime Interval initial value.
till DateTime Interval end value.
limit Number Default value: 100
Accepted values: 1 – 1000
offset Number Default value: 0
Accepted values: 0 – 100000

Response:

Name Type Description
timestamp DateTime Candle timestamp.
open String Opening value.
close String Closing value.
min String The lowest open interest for the period.
max String The highest open interest for the period.

Authentication

Public market data are available without authentication. Authentication is required for other requests.

You should create API keys on the API Settings page. You can create multiple API keys with different access rights for your applications.

Alternatively, you may obtain API keys via the Auth API by creating a session (POST /account/auth) and an API key (POST /api-key).

Basic

curl -u "apiKey:secretKey" "https://api.hitbtc.com/api/3/wallet/balance"
import requests

session = requests.session()
session.auth = ("apiKey", "secretKey")
const fetch = require('node-fetch');
const credentials = Buffer
  .from(
    'apiKey'
    + ':'
    + 'secretKey'
  )
  .toString('base64');

fetch(
  'https://api.hitbtc.com/api/3/wallet/balance',
  {
    method: 'GET',
    headers: {
      'Authorization': 'Basic ' + credentials
    }
  }
);

To authorize, place credentials to the request header. Those must be constituted of apiKey and secretKey as follows: "Basic " + apiKey + ":" + secretKey.

HS256

from base64 import b64encode
from hashlib import sha256
from hmac import HMAC
from time import time
from urllib.parse import urlsplit
from requests import Session
from requests.auth import AuthBase


class HS256(AuthBase):
    def __init__(self, api_key: str, secret_key: str, window: int = None):
        self.api_key = api_key
        self.secret_key = secret_key
        self.window = window

    def __call__(self, r):
        url = urlsplit(r.url)
        message = [r.method, url.path]
        if url.query:
            message.append('?')
            message.append(url.query)
        if r.body:
            message.append(r.body)

        timestamp = str(int(time() * 1000))
        window = str(self.window) if self.window else None
        message.append(timestamp)
        if window:
            message.append(window)

        signature = HMAC(key=self.secret_key.encode(),
                         msg=''.join(message).encode(),
                         digestmod=sha256).hexdigest()
        data = [self.api_key, signature, timestamp]
        if window:
            data.append(window)

        base64_encoded = b64encode(':'.join(data).encode()).decode()
        r.headers['Authorization'] = f'HS256 {base64_encoded}'
        return r


auth = HS256(api_key='apiKey', secret_key='secretKey')

with Session() as s:
    response = s.get('https://api.hitbtc.com/api/3/wallet/balance', auth=auth)
    print(response.json())

The alternative authentication method is the HMAC signature.

To send a request, you should establish a persistent session using the credentials signed as follows:

  1. Create an HMAC signature with secret_key as the secret key, SHA256 as the hash algorithm, and payload as the message, structured like:
    <method> + <URL path> + [“?” + <query>] + [<body>] + <timestamp> + [<window>]
  2. Add the authorization header to a request. It should have the following structure:
    "HS256 " + Base64(api_key + ":" + <HMAC signature> + ":" + timestamp + [":" + window])
Provided timestamp has to be valid in the specified sliding window (1000 – 60000 milliseconds) or default 10000 milliseconds.

Spot Trading

Order Model

{
  "id": 828680665,
  "client_order_id": "f4307c6e507e49019907c917b6d7a084",
  "symbol": "ETHBTC",
  "side": "sell",
  "status": "partiallyFilled",
  "type": "limit",
  "time_in_force": "GTC",
  "quantity": "13.942",
  "price": "0.011384",
  "quantity_cumulative": "5.240",
  "created_at": "2024-04-16T14:18:47.321Z",
  "updated_at": "2024-04-16T14:18:47.321Z",
  "post_only": false,
  "display_quantity": "0",
  "price_average": "0.011384",
  "trades": [
    {
      "id": 1361171432,
      "quantity": "5.240",
      "price": "0.011384",
      "fee": "0.001237803000",
      "taker": true,
      "timestamp": "2024-04-16T14:18:47.321Z"
    }
  ]
}

Order model consists of:

Name Type Description
id Number Unique order identifier as assigned by exchange.
client_order_id String Unique order identifier as assigned by the trader. Uniqueness must be guaranteed until the last order with the same client_order_id becomes inactive (canceled, expired, or fully executed) and some time after that.
order_list_id String Optional. Order list identifier. Returned only for an order list request.
contingency_type String Optional. Order list type. Returned only for an order list request.
Possible values:
allOrNone, oneCancelOther, oneTriggerOther, oneTriggerOneCancelOther
symbol String Symbol code.
side String Trade side.
Possible values: sell, buy
status String Order state.
Possible values:
new — an order is placed in the order book.
suspended — a stopLimit, stopMarket, takeProfitLimit or takeProfitMarket order is parked until it meets the conditions for placement in the order book.
partiallyFilled — an order is executed, but a part of its quantity is not filled yet.
filled — order quantity filled completely.
canceled — an order is canceled. It can either be done by a user through a cancel/replace request or by the system under specific circumstances.
expired — an order is deactivated after it no longer satisfies Time in Force (IOC, FOK) or Post Only requirements.
type String Order type.
Possible values: limit, market, stopLimit, stopMarket, takeProfitLimit, takeProfitMarket
time_in_force String Time in Force is a special instruction used when placing an order to indicate how long it will remain active before it is executed or expired.
GTC — "Good-Till-Canceled" order won't be closed until it is filled.
IOC — "Immediate-Or-Cancel" order must be executed immediately. Any part of an IOC order that cannot be filled immediately will be canceled.
FOK — "Fill-Or-Kill" order must be executed immediately and completely or not executed at all.
Day — keeps the order active until the end of the trading day (23:59 UTC+0).
GTD — "Good-Till-Date" order may remain active until the time specified in expire_time.
quantity String Order quantity.
quantity_cumulative String Executed order quantity.
price String Optional. Order price.
stop_price String Optional. The price level that triggers order activation. Specified if type is stopLimit, stopMarket, takeProfitLimit, or takeProfitMarket.
expire_time DateTime Optional. Date of order expiration. Specified if time_in_force is GTD.
post_only Boolean A post-only order is an order that does not remove liquidity. If a post-only order causes a match with a pre-existing order as a taker, then the order will expire.
display_quantity String Optional. The visible part of the hidden order quantity (the only valid value is "0").
original_client_order_id String Optional. Identifier of replaced order.
created_at DateTime Date of order's creation.
updated_at DateTime Date of order's last update.
trades []Trade Optional. List of trades. Never returned for an order list request.
price_average String Average price of executed order quantity.

Trade model consists of:

Name Type Description
id Number Trade identifier.
quantity String Quantity of trade.
price String Trade price.
fee String Fee paid for trade.
taker Boolean Liquidity indicator.
timestamp DateTime Date of trade.

Get Spot Trading Balance

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/spot/balance"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.get('https://api.hitbtc.com/api/3/spot/balance').json()

print(b)

Response. All currencies:

[
  {
    "currency": "ETH",
    "available": "10.000000000",
    "reserved": "0.56",
    "reserved_margin": "0",
    "cross_margin_reserved": "0"
  },
  {
    "currency": "BTC",
    "available": "0.010205869",
    "reserved": "0",
    "reserved_margin": "0",
    "cross_margin_reserved": "0"
  }
]

Response. One currency:

{
  "available": "10.000000000",
  "reserved": "0.56",
  "reserved_margin": "0",
  "cross_margin_reserved": "0"
}

GET /api/3/spot/balance GET /api/3/spot/balance/{currency}

Returns the user's trading balance.

Requires the "Orderbook, History, Trading balance" API key Access Right.

Parameters:

Name Type Description
currency String Optional. Currency filter.

Response:

Name Type Description
currency String Currency code.
available String Amount available for trading or transfer to wallet.
reserved_margin String Amount reserved for margin trading.
cross_margin_reserved String Amount reserved for margin trading funded by a cross–margin account.
reserved String Total amount reserved for active orders and incomplete transfers to wallet.

Get All Active Spot Orders

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/spot/order"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.get('https://api.hitbtc.com/api/3/spot/order').json()

print(b)

Response:

[
  {
    "id": 840450210,
    "client_order_id": "c1837634ef81472a9cd13c81e7b91401",
    "symbol": "ETHBTC",
    "side": "buy",
    "status": "partiallyFilled",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "0.020",
    "price": "0.046001",
    "quantity_cumulative": "0.005",
    "post_only": false,
    "created_at": "2024-04-12T17:17:57.437Z",
    "updated_at": "2024-04-12T17:18:08.610Z"
  }
]

GET /api/3/spot/order

Returns a list of all active spot orders.

Requires the "Orderbook, History, Trading balance" API key Access Right.

Parameters:

Name Type Description
symbol String Optional. Parameter to filter active spot orders by symbol.

Response: array of spot orders

Get Active Spot Order

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/spot/order/c1837634ef81472a9cd13c81e7b91401"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.get('https://api.hitbtc.com/api/3/spot/order/c1837634ef81472a9cd13c81e7b91401').json()

print(b)

Response:

{
  "id": 840450210,
  "client_order_id": "c1837634ef81472a9cd13c81e7b91401",
  "symbol": "ETHBTC",
  "side": "buy",
  "status": "partiallyFilled",
  "type": "limit",
  "time_in_force": "GTC",
  "quantity": "0.020",
  "price": "0.046001",
  "quantity_cumulative": "0.005",
  "post_only": false,
  "created_at": "2024-04-12T17:17:57.437Z",
  "updated_at": "2024-04-12T17:18:08.610Z"
}

GET /api/3/spot/order/{client_order_id}

Returns an active spot order by client_order_id.

Requires the "Orderbook, History, Trading balance" API key Access Right.

Response: spot order

Create New Spot Order

curl \
  -X POST \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/spot/order" \
  -d "symbol=ETHBTC&side=sell&quantity=0.063&price=0.046016"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")
orderData = {'symbol':'ETHBTC', 'side': 'sell', 'quantity': '0.063', 'price': '0.046016' }

r = session.post('https://api.hitbtc.com/api/3/spot/order/', data = orderData)

print(r.json())

Response:

{
  "id": 0,
  "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
  "symbol": "ETHBTC",
  "side": "sell",
  "status": "new",
  "type": "limit",
  "time_in_force": "GTC",
  "quantity": "0.063",
  "price": "0.046016",
  "quantity_cumulative": "0.000",
  "post_only": false,
  "created_at": "2024-04-15T17:01:05.092Z",
  "updated_at": "2024-04-15T17:01:05.092Z"
}

Error response example:

{
  "error": {
    "code": 20001,
    "message": "Insufficient funds",
    "description": "Check that the funds are sufficient, given commissions"
  }
}

POST /api/3/spot/order

Creates a new spot order.

Requires the "Place/cancel orders" API key Access Right.

Parameters:

Name Type Description
client_order_id String Optional. If omitted, an order will be created, and it will be generated by the Server. Uniqueness must be guaranteed until the last order with the same client_order_id becomes inactive (canceled, expired, or fully executed) and some time after that.
Must be from 8 to 32 long. May include Latin letters of any case, digits, and _, -.
If specified and corresponds to an existing order, a request will be rejected.
symbol String Symbol code.
side String Trade side.
Accepted values: sell, buy
type String Optional. Order type.
Must be set to market, stopMarket, or takeProfitMarket if price was left unspecified.
Accepted values: limit, market, stopLimit, stopMarket, takeProfitLimit, takeProfitMarket
Default value: limit
time_in_force String Optional. Time in Force instruction.
Accepted values: GTC, IOC, FOK, Day, GTD
Default value:
FOK — type is market, stopMarket, takeProfitMarket;
GTC — type is limit, stopLimit, takeProfitLimit.
quantity Number Order quantity.
price Number Order price. Required if type is limit, stopLimit, or takeProfitLimit.
stop_price Number The price level that triggers order activation. Required if type is stopLimit, stopMarket, takeProfitLimit, or takeProfitMarket.
expire_time DateTime Date of order expiration. Required if time_in_force is GTD.
strict_validate Boolean Price and quantity will be checked for incrementation within the symbol’s tick size and quantity step. See the symbol's tick_size and quantity_increment.
post_only Boolean Optional. If a post-only order causes a match with a pre-existing order as a taker, then the order will expire.
display_quantity String Optional. The visible part of the hidden order quantity (the only valid value is "0").
take_rate Number Optional. Liquidity taker fee, a fraction of order volume, such as 0.001 (for 0.1% fee). Can only increase the fee. Used for fee markup.
make_rate Number Optional. Liquidity provider fee, a fraction of order volume, such as 0.001 (for 0.1% fee). Can only increase the fee. Used for fee markup.
Execution of a taker's order may be postponed for 1 millisecond.

Response: spot order

Price accuracy and quantity

Symbol config contains the tick_size parameter which means that price should be divided by tick_size with no remainder.
quantity should be divided by quantity_increment with no remainder.
By default, if strict_validate is not enabled, the Server rounds half down the price and quantity for tick_size and quantity_increment.

Example of ETHBTC: if tick_size is 0.000001, then price 0.046016 is valid, and 0.0460165 is invalid.

Fees

Charged fee is determined by the symbol's fee_currency. Maker-taker fees offer a transaction rebate make_rate to those who provide liquidity (a maker), while charging customers who take that liquidity take_rate (a taker).

To create buy orders, you must have sufficient balance including fees.

To create market buy orders, you must have sufficient balance including fees.

Available balance > price × quantity + price × quantity × max(take_rate, make_rate)

Order result status

For orders with time_in_force equal to IOC or FOK, the REST API returns final order status: filled or expired.

If an order can be instantly executed, then the REST API returns a status of filled or partiallyFilled in the order's info.

Create New Spot Order List

AON request:

curl \
  -X POST \
  -H 'Content-Type: application/json'\
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/spot/order/list" \
  -d '{
        "contingency_type": "allOrNone",
        "orders": [
          {
            "symbol": "ETHBTC",
            "side": "sell",
            "quantity": "0.063",
            "type": "market",
            "time_in_force": "FOK"
          },
          {
            "symbol": "BTCUSDT",
            "side": "sell",
            "quantity": "0.057",
            "type": "market",
            "time_in_force": "FOK"
          }
        ]
      }'
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")
headers = {'Content-Type': 'application/json'}
orderData = '{"contingency_type": "allOrNone", "orders": [{"symbol": "ETHBTC", "side": "sell", "quantity": "0.063", "type": "market", "time_in_force": "FOK"}, {"symbol": "BTCUSDT", "side": "sell", "quantity": "0.057", "type": "market", "time_in_force": "FOK"}]}'

r = session.post('https://api.hitbtc.com/api/3/spot/order/list', data = orderData, headers=headers)

print(r.json())

AON response:

[
  {
    "id": 840450210,
    "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
    "symbol": "ETHBTC",
    "side": "sell",
    "status": "filled",
    "type": "market",
    "time_in_force": "FOK",
    "quantity": "0.063",
    "price": "0.071476",
    "quantity_cumulative": "0.000",
    "post_only": false,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "allOrNone",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  },
  {
    "id": 840450211,
    "client_order_id": "a53406ea49e160c63b620ca21e9fb634",
    "symbol": "BTCUSDT",
    "side": "sell",
    "status": "filled",
    "type": "market",
    "time_in_force": "FOK",
    "quantity": "0.057",
    "price": "43510.67",
    "quantity_cumulative": "0.000",
    "post_only": false,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "allOrNone",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  }
]

OCO request:

curl \
  -X POST \
  -H 'Content-Type: application/json' \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/spot/order/list" \
  -d '{
        "contingency_type": "oneCancelOther",
        "orders": [
          {
            "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
            "symbol": "ETHBTC",
            "side": "buy",
            "type": "limit",
            "time_in_force": "GTC",
            "quantity": "0.063",
            "price": "0.046016",
            "post_only": false
          },
          {
            "client_order_id": "a53406ea49e160c63b620ca21e9fb634",
            "symbol": "ETHBTC",
            "side": "sell",
            "type": "stopMarket",
            "time_in_force": "GTC",
            "quantity": "0.063",
            "stop_price": "0.044050",
            "post_only": false
          }
        ]
      }'
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")
headers = {'Content-Type': 'application/json'}
orderData = '{"contingency_type": "oneCancelOther", "orders": [{"client_order_id": "d8574207d9e3b16a4a5511753eeef175", "symbol": "ETHBTC", "side": "buy", "type": "limit", "time_in_force": "GTC", "quantity": "0.063", "price": "0.046016", "post_only": false}, {"client_order_id": "a53406ea49e160c63b620ca21e9fb634", "symbol": "ETHBTC", "side": "sell", "type": "stopMarket", "time_in_force": "GTC", "quantity": "0.063", "stop_price": "0.044050", "post_only": false}]}'

r = session.post('https://api.hitbtc.com/api/3/spot/order/list', data = orderData, headers=headers)

print(r.json())

OCO response:

[
  {
    "id": 840450210,
    "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
    "symbol": "ETHBTC",
    "side": "buy",
    "status": "new",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "price": "0.046016",
    "quantity_cumulative": "0.063",
    "post_only": false,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneCancelOther",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  },
  {
    "id": 840450211,
    "client_order_id": "a53406ea49e160c63b620ca21e9fb634",
    "symbol": "ETHBTC",
    "side": "sell",
    "status": "suspended",
    "type": "stopMarket",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "quantity_cumulative": "0.057",
    "post_only": false,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneCancelOther",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  }
]

OTO request:

curl \
  -X POST \
  -H 'Content-Type: application/json' \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/spot/order/list" \
  -d '{
        "contingency_type": "oneTriggerOther",
        "orders": [
          {
            "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
            "symbol": "ETHBTC",
            "side": "buy",
            "type": "limit",
            "time_in_force": "GTC",
            "quantity": "0.063",
            "price": "0.046016",
            "post_only": false
          },
          {
            "client_order_id": "a53406ea49e160c63b620ca21e9fb634",
            "symbol": "ETHBTC",
            "side": "sell",
            "type": "stopMarket",
            "time_in_force": "GTC",
            "quantity": "0.063",
            "stop_price": "0.044050",
            "post_only": false
          }
        ]
      }'
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")
headers = {'Content-Type': 'application/json'}
orderData = '{"contingency_type": "oneTriggerOther", "orders": [{"client_order_id": "d8574207d9e3b16a4a5511753eeef175", "symbol": "ETHBTC", "side": "buy", "type": "limit", "time_in_force": "GTC", "quantity": "0.063", "price": "0.046016", "post_only": false}, {"client_order_id": "a53406ea49e160c63b620ca21e9fb634", "symbol": "ETHBTC", "side": "sell", "type": "stopMarket", "time_in_force": "GTC", "quantity": "0.063", "stop_price": "0.044050", "post_only": false}]}'

r = session.post('https://api.hitbtc.com/api/3/spot/order/list', data = orderData, headers=headers)

print(r.json())

OTO response:

[
  {
    "id": 840450210,
    "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
    "symbol": "ETHBTC",
    "side": "buy",
    "status": "new",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "price": "0.046016",
    "quantity_cumulative": "0.063",
    "post_only": false,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneTriggerOther",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  },
  {
    "id": 840450211,
    "client_order_id": "a53406ea49e160c63b620ca21e9fb634",
    "symbol": "ETHBTC",
    "side": "sell",
    "status": "suspended",
    "type": "stopMarket",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "quantity_cumulative": "0.057",
    "post_only": false,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneTriggerOther",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  }
]

OTOCO request:

curl \
  -X POST \
  -H 'Content-Type: application/json' \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/spot/order/list" \
  -d '{
        "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
        "contingency_type": "oneTriggerOneCancelOther",
        "orders": [
          {
            "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
            "symbol": "ETHBTC",
            "side": "buy",
            "type": "limit",
            "time_in_force": "GTC",
            "quantity": "0.063",
            "price": "0.046016",
            "post_only": false
          },
          {
            "client_order_id": "2723cdfba2d609b621d5d055e3ef9be2",
            "symbol": "ETHBTC",
            "side": "sell",
            "type": "limit",
            "time_in_force": "GTC",
            "quantity": "0.063",
            "price": "0.050000",
            "post_only": false
          },
          {
            "client_order_id": "a53406ea49e160c63b620ca21e9fb634",
            "symbol": "ETHBTC",
            "side": "sell",
            "type": "stopMarket",
            "time_in_force": "GTC",
            "quantity": "0.063",
            "stop_price": "0.044050",
            "post_only": false
          }
        ]
      }'
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")
headers = {'Content-Type': 'application/json'}
orderData = '{"contingency_type": "oneTriggerOneCancelOther", "orders": [{"client_order_id": "d8574207d9e3b16a4a5511753eeef175", "symbol": "ETHBTC", "side": "buy", "type": "limit", "time_in_force": "GTC", "quantity": "0.063", "price": "0.046016", "post_only": false}, {"client_order_id": "2723cdfba2d609b621d5d055e3ef9be2", "symbol": "ETHBTC", "side": "sell", "type": "limit", "time_in_force": "GTC", "quantity": "0.063", "price": "0.050000", "post_only": false}, {"client_order_id": "a53406ea49e160c63b620ca21e9fb634", "symbol": "ETHBTC", "side": "sell", "type": "stopMarket", "time_in_force": "GTC", "quantity": "0.063", "stop_price": "0.044050", "post_only": false}]}'

r = session.post('https://api.hitbtc.com/api/3/spot/order/list', data = orderData, headers=headers)

print(r.json())

OTOCO response:

[
  {
    "id": 840450210,
    "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
    "symbol": "ETHBTC",
    "side": "buy",
    "status": "new",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "price": "0.046016",
    "quantity_cumulative": "0.000",
    "post_only": false,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneTriggerOneCancelOther",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  },
  {
    "id": 840450211,
    "client_order_id": "2723cdfba2d609b621d5d055e3ef9be2",
    "symbol": "ETHBTC",
    "side": "sell",
    "status": "new",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "price": "0.050000",
    "quantity_cumulative": "0.000",
    "post_only": false,
    "inactive": true,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneTriggerOneCancelOther",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  },
  {
    "id": 840450211,
    "client_order_id": "a53406ea49e160c63b620ca21e9fb634",
    "symbol": "ETHBTC",
    "side": "sell",
    "status": "suspended",
    "type": "stopMarket",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "stop_price": "0.044050",
    "quantity_cumulative": "0.000",
    "post_only": false,
    "inactive": true,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneTriggerOneCancelOther",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  }
]

Error response example:

{
  "error": {
    "code": 20001,
    "message": "Insufficient funds",
    "description": "Check that the funds are sufficient, given commissions"
  }
}

POST /api/3/spot/order/list

Creates a new spot order list.

Requires the "Place/cancel orders" API key Access Right.

Parameters:

Name Type Description
order_list_id String Order list identifier. If omitted, it will be generated by the system upon order list creation. Must be equal to client_order_id of the first order in the request.
contingency_type String Order list type.
Accepted values:
allOrNone (AON) — all orders in the set should be executed within a single transaction or become expired otherwise;
oneCancelOther (OCO) — all orders in the set should be canceled if one of them was executed;
oneTriggerOther (OTO) — execution of the first (primary) order on the list activates other (secondary) orders as independent of each other;
oneTriggerOneCancelOther (OTOCO) — the execution of the first (primary) order on the list activates the other (secondary) orders as an OCO order list.
orders []Order Orders in the list. There must be 2 or 3 orders for allOrNone/oneCancelOther/oneTriggerOther and 3 — for oneTriggerOneCancelOther. Placing any other number of orders will result in an error.

Order model consists of:

Name Type Description
client_order_id String Optional. Must be different from the identifiers of other orders in the list.
If omitted, it will be generated by the system upon order list creation. Uniqueness must be guaranteed until the last order with the same client_order_id becomes inactive (canceled, expired, or fully executed) and some time after that.
symbol String Symbol code.
For a allOrNone order list, symbol code must be unique for each order in the list.
For an oneTriggerOneCancelOther order list, symbol code must be the same for all orders in the list (placing orders in different order books is not supported).
side String Trade side.
Accepted values: sell, buy
type String Optional. Order type.
Accepted values:
for allOrNone — limit, market;
for oneCancelOther (and secondary orders in oneTriggerOneCancelOther) — limit, stopLimit, stopMarket, takeProfitLimit, takeProfitMarket;
for oneTriggerOneCancelOther — limit, market, stopLimit, stopMarket, takeProfitLimit, takeProfitMarket.
Default value: limit
time_in_force String Optional (required for allOrNone). Time in Force instruction.
Accepted values:
for allOrNone — FOK;
for oneCancelOther (and secondary orders in oneTriggerOneCancelOther) — GTC, IOC (except limit orders), FOK (except limit orders), Day, GTD;
for oneTriggerOneCancelOther — GTC, IOC, FOK, Day, GTD.
quantity String Order quantity.
price String Order price. Required if type is limit, stopLimit, or takeProfitLimit.
stop_price String The price level that triggers order activation. Required if type is stopLimit, stopMarket, takeProfitLimit, or takeProfitMarket.
expire_time DateTime Date of order expiration. Required if time_in_force is GTD.
strict_validate Boolean Price and quantity will be checked for incrementation within the symbol’s tick size and quantity step. See the symbol's tick_size and quantity_increment.
post_only Boolean Optional. If a post-only order causes a match with a pre-existing order as a taker, then the order will expire.
display_quantity String Optional. The visible part of the hidden order quantity (the only valid value is '0').
take_rate String Optional. Liquidity taker fee, a fraction of order volume, such as 0.001 (for 0.1% fee). Can only increase the fee. Used for fee markup.
make_rate String Optional. Liquidity provider fee, a fraction of order volume, such as 0.001 (for 0.1% fee). Can only increase the fee. Used for fee markup.
An OCO order list cannot include more than one limit order (the same applies to secondary orders in an OTOCO order list).

Response: array of spot orders

Replace Spot Order

curl \
  -X PATCH \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/spot/order/d8574207d9e3b16a4a5511753eeef174" \
  -d "quantity=0.063&price=0.046016&new_client_order_id=d8574207d9e3b16a4a5511753eeef175"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")
orderData = {'quantity': '0.063', 'price': '0.046016', 'new_client_order_id': 'd8574207d9e3b16a4a5511753eeef175'}

r = session.patch('https://api.hitbtc.com/api/3/spot/order/d8574207d9e3b16a4a5511753eeef174', data = orderData)

print(r.json())

Response:

{
  "id": 0,
  "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
  "symbol": "ETHBTC",
  "side": "sell",
  "status": "new",
  "type": "limit",
  "time_in_force": "GTC",
  "quantity": "0.063",
  "price": "0.046016",
  "quantity_cumulative": "0.000",
  "post_only": false,
  "created_at": "2024-04-15T17:01:05.092Z",
  "updated_at": "2024-04-15T17:01:05.092Z"
}

Error response example:

{
  "error": {
    "code": 20001,
    "message": "Insufficient funds",
    "description": "Check that the funds are sufficient, given commissions"
  }
}

PATCH /api/3/spot/order/{client_order_id}

Replaces a spot order

Requires the "Place/cancel orders" API key Access Right.

Parameters:

Name Type Description
new_client_order_id String Optional. client_order_id for a new order.
quantity Number Order quantity.
price Number Optional. Order price. Required if type is limit, stopLimit, or takeProfitLimit.
stop_price Number Optional. The price level that triggers order activation. Specified if type is stopLimit, stopMarket, takeProfitLimit, or takeProfitMarket.
strict_validate Boolean Optional. Price and quantity will be checked for incrementation within the symbol’s tick size and quantity step. See the symbol's tick_size and quantity_increment.

Response: spot order

Cancel All Spot Orders

DELETE /api/3/spot/order

Cancels all active spot orders.

Requires the "Place/cancel orders" API key Access Right.

Parameters:

Name Type Description
symbol String Optional. Parameter to filter active spot orders by symbol.

Response: array of spot orders

Cancel Spot Order

curl \
  -X DELETE \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/spot/order/d8574207d9e3b16a4a5511753eeef175"

Response:

{
  "id": 0,
  "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
  "symbol": "ETHBTC",
  "side": "sell",
  "status": "canceled",
  "type": "limit",
  "time_in_force": "GTC",
  "quantity": "0.063",
  "price": "0.046016",
  "quantity_cumulative": "0.000",
  "post_only": false,
  "created_at": "2024-04-15T17:01:05.092Z",
  "updated_at": "2024-04-15T17:01:05.092Z"
}

Example of Order not found error response:

{
  "error": {
    "code": 20002,
    "message": "Order not found",
    "description": ""
  }
}

DELETE /api/3/spot/order/{client_order_id}

Cancels a spot order.

Requires the "Place/cancel orders" API key Access Right.

Response: spot order

Get All Trading Commissions

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/spot/fee"

Response:

[
  {
    "symbol": "BTCUSDT",
    "take_rate": "0.001",
    "make_rate": "-0.0001"
  },
  {
    "symbol": "ETHBTC",
    "take_rate": "0.001",
    "make_rate": "-0.0001"
  }
]

GET /api/3/spot/fee

Returns personal trading commission rates for all symbols.

Requires the "Orderbook, History, Trading balance" API key Access Right.

Get Trading Commission

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/spot/fee/ETHBTC"

Response:

{
  "take_rate": "0.001",
  "make_rate": "-0.0001"
}

GET /api/3/spot/fee/{symbol}

Returns personal trading commission rate by symbol.

Requires the "Place/cancel orders" API key Access Right.

Spot Trading History

Please note that trading history may be updated with a delay up to 30 seconds, with a mean delay of around 1 second.

Spot Orders History

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/spot/history/order?symbol=ETHBTC"
[
  {
    "id": 828680665,
    "client_order_id": "f4307c6e507e49019907c917b6d7a084",
    "symbol": "ETHBTC",
    "side": "sell",
    "status": "partiallyFilled",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "13.942",
    "price": "0.011384",
    "price_average": "0.055487",
    "quantity_cumulative": "5.240",
    "created_at": "2024-04-16T14:18:47.321Z",
    "updated_at": "2024-04-19T15:23:54.876Z"
  },
  {
    "id": 828680667,
    "client_order_id": "f4307c6e507e49019907c917b6d7a084",
    "symbol": "ETHBTC",
    "side": "sell",
    "status": "partiallyFilled",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "13.942",
    "price": "0.011384",
    "price_average": "0.045000",
    "quantity_cumulative": "5.240",
    "created_at": "2024-04-16T14:18:50.321Z",
    "updated_at": "2024-04-19T15:23:56.876Z"
  }
]

GET /api/3/spot/history/order

Returns all spot orders. Orders without executions are deleted after 24 hours.

Requires the "Orderbook, History, Trading balance" API key Access Right.

All parameters are optional.

Parameters:

Name Type Description
client_order_id String If specified, other parameters will be ignored, including limit and offset.
symbol String Comma-separated symbol codes.
statuses String Optional. Filter by order status.
Comma-separated array.
Possible values: suspended, new, partiallyFilled, filled, canceled, expired,rejected`
sort String Sort direction.
Accepted values: DESC, ASC
Default value: DESC
by String Filter type.
Accepted values: timestamp, id
Default value: id
from DateTime Interval initial value.
till DateTime Interval end value.
limit Number Default value: 100
Maximum value: 1000
offset Number Default value: 0
Maximum value: 100000

Response:

Name Type Description
id Number Unique order identifier as assigned by exchange.
client_order_id String Unique order identifier as assigned by the trader. The order history may list several orders with the same client_order_id.
symbol String Symbol code.
side String Trade side.
Possible values: sell, buy
status String Order state.
Possible values:
new — an order is placed in the order book.
suspended — a stopLimit, stopMarket, takeProfitLimit or takeProfitMarket order is parked until it meets the conditions for placement in the order book.
partiallyFilled — an order is executed, but a part of its quantity is not filled yet.
filled — order quantity filled completely.
canceled — an order is canceled. It can either be done by a user through a cancel/replace request or by the system under specific circumstances.
expired — an order is deactivated after it no longer satisfies Time in Force (IOC, FOK) or Post Only requirements.
type String Order type.
Possible values: limit, market, stopLimit, stopMarket, takeProfitLimit, takeProfitMarket
time_in_force String Time in Force is a special instruction used when placing an order to indicate how long it will remain active before it is executed or expired.
GTC — "Good-Till-Canceled" order won't be closed until it is filled.
IOC — "Immediate-Or-Cancel" order must be executed immediately. Any part of an IOC order that cannot be filled immediately will be canceled.
FOK — "Fill-Or-Kill" order must be executed immediately and completely or not executed at all.
Day — keeps the order active until the end of the trading day (23:59 UTC+0).
GTD — "Good-Till-Date" order may remain active until the time specified in expire_time.
quantity String Order quantity.
quantity_cumulative String Executed order quantity.
display_quantity String The visible part of the hidden order quantity.
price String Order price.
price_average String Average price of executed order quantity.
expire_time DateTime Date of order expiration. Specified if time_in_force is GTD.
stop_price String The price level that triggers order activation. Specified if type is stopLimit, stopMarket, takeProfitLimit, or takeProfitMarket.
created_at DateTime Date of order's creation.
updated_at DateTime Date of order's last update.
order_list_id String Optional. Order list identifier.
contingency_type String Optional. Order list type.
Possible values:
allOrNone, oneCancelOther, oneTriggerOther, oneTriggerOneCancelOther

Spot Trades History

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/spot/history/trade?symbol=ETHBTC"
[
  {
    "id": 9535486,
    "order_id": 816088377,
    "client_order_id": "f8dbaab336d44d5ba3ff578098a68454",
    "symbol": "ETHBTC",
    "side": "sell",
    "quantity": "0.061",
    "price": "0.045487",
    "fee": "0.000002775",
    "timestamp": "2024-04-17T12:32:57.848Z",
    "taker": true
  },
  {
    "id": 9535437,
    "order_id": 816088021,
    "client_order_id": "27b9bfc068b44194b1f453c7af511ed6",
    "symbol": "ETHBTC",
    "side": "buy",
    "quantity": "0.038",
    "price": "0.046000",
    "fee": "-0.000000174",
    "timestamp": "2024-04-17T12:30:57.848Z",
    "taker": true
  }
]

GET /api/3/spot/history/trade

Returns the user's spot trading history.

Requires the "Orderbook, History, Trading balance" API key Access Right.

All parameters are optional.

Parameters:

Name Type Description
order_id String Unique order identifier as assigned by exchange.
symbol String Comma-separated symbol codes.
sort String Sort direction.
Accepted values: DESC, ASC
Default value: DESC
by String Filter type.
Accepted values: timestamp, id
Default value: id
from DateTime or Number Interval initial value.
If sorting by timestamp is used, then DateTime; otherwise — Number.
till DateTime or Number Interval end value.
If sorting by timestamp is used, then DateTime; otherwise — Number.
limit Number Default value: 100
Maximum value: 1000
offset Number Default value: 0
Maximum value: 100000

Response:

Name Type Description
id Number Trade unique identifier as assigned by exchange.
order_id Number Unique order identifier as assigned by exchange.
client_order_id String Unique order identifier as assigned by the trader. The order history may list several orders with the same client_order_id.
symbol String Symbol code.
side String Trade side.
Possible values: sell, buy
quantity String Trade quantity.
price String Trade price.
fee String Trade commission.
Can be negative ("rebate" — reward paid to the trader). See fee currency in the symbol config.
timestamp DateTime Trade timestamp.
taker Boolean Liquidity indicator.

Margin Settings

Margin settings define how the margin of a margin account is managed:

  • AMM (auto margin management) — the platform reserves and releases the margin of a margin account automatically;
  • AMR (auto margin replenishment) — the platform replenishes the margin of a position from the trading balance to prevent liquidation.

Auto Margin Management

With AMM enabled for a margin account:

  • the margin required for an order and for the position the order opens is reserved from the trading balance at the moment the order is placed;
  • the reserve is recalculated when an order is canceled or replaced and when the position leverage is changed;
  • the margin is released back to the trading balance once all the positions of the margin account are closed and no active orders are left;
  • the margin account and the position are created by the first order, so neither creating a margin account nor reserving margin for it in advance is required.

Placing an order with AMM enabled:

  1. Place a new order with margin_auto set to true: POST /api/3/margin/order or the margin_new_order socket method; POST /api/3/futures/order or the futures_new_order socket method.
  2. The platform creates the margin account and the position if they do not exist yet and reserves the margin required for the order from the trading balance. If the available balance is not sufficient, the order is rejected with the 20003 error code, and the objects created for it are removed.
  3. The reserved margin is released back to the trading balance once the position is closed completely and the margin account has no active orders left.

The margin management mode is a property of the margin account, and the value passed in an order is applied to it as follows:

  • the values of the order and of the account are the same — the value is kept;
  • the values differ and the account is idle, meaning that it has neither open positions nor active orders — the value of the order is applied to the account;
  • the values differ, but the account is not idle — the value of the account is kept, and the value of the order is ignored.
Manual margin management is fully supported. With margin_auto set to false, a margin account behaves as before: it has to be created and funded with a margin account request, and the reserved margin is retrieved the same way.

Auto Margin Replenishment

AMR (auto margin replenishment) prevents a position from being liquidated: as soon as the margin of the position reaches the liquidation level, the platform cancels the active orders of the margin account and, if that is not enough, reserves additional margin from the trading balance instead of liquidating the position.

  • AMR is applied to both the automatic and the manual margin management modes.
  • For an isolated margin account, AMR is a property of the position; for a cross-margin account, it is a property of the account and is applied to all of its positions at once.
  • The default value is false for an isolated margin account, while for a cross-margin account it is defined by the platform settings.
  • With AMM enabled, the flag is reset to its default value once all the positions of the margin account are closed.
  • The current value is returned in the amr field of margin account and position models and reports.
With AMR enabled, the entire available trading balance may be spent on replenishing the margin of a losing position.

Get Margin Settings

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin-settings"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.get('https://api.hitbtc.com/api/3/margin-settings').json()

print(b)

Response:

{
  "default_amm": false,
  "user_can_change_amm": true,
  "user_can_change_amr_isolated": true,
  "user_can_change_amr_cross": true,
  "current_amm": true,
  "amm_override_set": true
}

GET /api/3/margin-settings

Returns the AMM and AMR settings of the user.

Requires the "Orderbook, History, Trading balance" API key Access Right.

Response:

Name Type Description
default_amm Boolean Default value of the AMM flag on the platform.
user_can_change_amm Boolean Flag indicating whether the user is allowed to change the AMM flag.
user_can_change_amr_isolated Boolean Flag indicating whether the user is allowed to change the AMR flag of isolated margin accounts.
user_can_change_amr_cross Boolean Flag indicating whether the user is allowed to change the AMR flag of cross-margin accounts.
current_amm Boolean Effective value of the AMM flag of the user: either the value set by the user or the default one.
This is the value the exchange web interface puts into margin_auto of every new order.
amm_override_set Boolean Flag indicating whether the user has set an own value of the AMM flag instead of the default one.

Set Auto Margin Management

curl \
  -X PUT \
  -u "apiKey:secretKey" \
  -H "Content-Type: application/json" \
  "https://api.hitbtc.com/api/3/margin-settings/amm" \
  -d '{"amm": true}'
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.put('https://api.hitbtc.com/api/3/margin-settings/amm', json={"amm": True}).json()

print(b)

Response:

{
  "amm": true
}

PUT /api/3/margin-settings/amm

Changes the AMM flag of the user.

The new value is applied to the orders placed after the request, while the margin accounts that are already in a fixed margin management mode keep it.

Requires the "Place/cancel orders" API key Access Right.

Parameters:

Name Type Description
amm Boolean New value of the AMM flag of the user.

Response:

Name Type Description
amm Boolean Value of the AMM flag of the user.
The request is rejected with the 1005 error code if user_can_change_amm is false, and with the 65 error code if AMM is disabled on the platform.

Set Auto Margin Replenishment

curl \
  -X PUT \
  -u "apiKey:secretKey" \
  -H "Content-Type: application/json" \
  "https://api.hitbtc.com/api/3/margin/margin-settings/amr" \
  -d '{"margin_mode": "isolated", "symbol": "BTCUSDT", "amr": true}'
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.put('https://api.hitbtc.com/api/3/margin/margin-settings/amr', json={"margin_mode": "cross", "currency": "USDT", "amr": True}).json()

print(b)

Response:

{
  "margin_mode": "isolated",
  "symbol": "BTCUSDT",
  "amr": true
}

PUT /api/3/margin/margin-settings/amr

PUT /api/3/futures/margin-settings/amr

Changes the AMR flag of a margin account: an isolated one addressed by symbol or a cross-margin one addressed by currency.

The margin account must exist, otherwise the request is rejected with the 10025 error code.

Setting the value the margin account already has is not an error: the current state is returned, but no report is sent.

Requires the "Place/cancel orders" API key Access Right.

Parameters:

Name Type Description
margin_mode String Margin mode.
Accepted values: isolated, cross
symbol String Symbol code of the isolated margin account.
Conditions: margin_mode is isolated, must be omitted otherwise.
currency String Currency code of the cross-margin account.
Conditions: margin_mode is cross, must be omitted otherwise.
amr Boolean New value of the AMR flag of the margin account.

Response:

Name Type Description
margin_mode String Margin mode.
Possible values: isolated, cross
symbol String Symbol code of the isolated margin account.
currency String Currency code of the cross-margin account.
amr Boolean Current value of the AMR flag of the margin account.

Once the flag is changed, a report with the amrChanged report reason is sent to the subscribers:

  • a position report — for an isolated margin account;
  • a margin account report — for a cross-margin account.
The request is rejected with the 1005 error code if changing the AMR flag for the requested margin mode is not allowed for the user (see user_can_change_amr_isolated and user_can_change_amr_cross), and with the 65 error code if AMM is disabled on the platform.

Margin Trading

Learn how margin trading works at our support center https://support.hitbtc.com/en/support/solutions/articles/63000225029-what-is-margin-trading

Margin Order Model

Margin Order:

{
  {
    "id": 828680665,
    "client_order_id": "f4307c6e507e49019907c917b6d7a084",
    "symbol": "ETHBTC",
    "side": "sell",
    "status": "partiallyFilled",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "13.942",
    "price": "0.011384",
    "quantity_cumulative": "5.240",
    "created_at": "2024-04-16T14:18:47.321Z",
    "updated_at": "2024-04-16T14:18:47.321Z",
    "post_only": false,
    "display_quantity": "0",
    "margin_mode": "isolated",
    "margin_auto": true,
    "price_average": "0.011384",
    "trades": [
      {
        "id": 1361171432,
        "position_id": 123,
        "quantity": "5.240",
        "price": "0.011384",
        "fee": "0.001237803000",
        "taker": true,
        "timestamp": "2024-04-16T14:18:47.321Z"
      }
    ]
  }
}

Margin order model consists of:

Name Type Description
id Number Unique order identifier as assigned by exchange.
client_order_id String Unique order identifier as assigned by the trader. Uniqueness must be guaranteed until the last order with the same client_order_id becomes inactive (canceled, expired, or fully executed) and some time after that.
order_list_id String Optional. Order list identifier.
contingency_type String Optional. Order list type.
Possible values:
allOrNone, oneCancelOther, oneTriggerOther, oneTriggerOneCancelOther
symbol String Symbol code.
side String Trade side.
Possible values: sell, buy
status String Order state.
Possible values:
new — an order is placed in the order book.
suspended — a stopLimit, stopMarket, takeProfitLimit or takeProfitMarket order is parked until it meets the conditions for placement in the order book.
partiallyFilled — an order is executed, but a part of its quantity is not filled yet.
filled — order quantity filled completely.
canceled — an order is canceled. It can either be done by a user through a cancel/replace request or by the system under specific circumstances.
expired — an order is deactivated after it no longer satisfies Time in Force (IOC, FOK) or Post Only requirements.
type String Order type.
Possible values: limit, market, stopLimit, stopMarket, takeProfitLimit, takeProfitMarket
time_in_force String Time in Force is a special instruction used when placing an order to indicate how long it will remain active before it is executed or expired.
GTC — "Good-Till-Canceled" order won't be closed until it is filled.
IOC — "Immediate-Or-Cancel" order must be executed immediately. Any part of an IOC order that cannot be filled immediately will be canceled.
FOK — "Fill-Or-Kill" order must be executed immediately and completely or not executed at all.
Day — keeps the order active until the end of the trading day (23:59 UTC+0).
GTD — "Good-Till-Date" order may remain active until the time specified in expire_time.
quantity String Order quantity.
quantity_cumulative String Executed order quantity.
price String Optional. Order price.
stop_price String Optional. The price level that triggers order activation. Specified if type is stopLimit, stopMarket, takeProfitLimit, or takeProfitMarket.
expire_time DateTime Optional. Date of order expiration. Specified if time_in_force is GTD.
post_only Boolean A post-only order is an order that does not remove liquidity. If a post-only order causes a match with a pre-existing order as a taker, then the order will expire.
reduce_only Boolean Reduce-only order, being filled, guarantees not to put the position quantity to the point when the position flips.
close_position Boolean Flag indicating a stop market order must close a margin position when executed or be canceled otherwise.
display_quantity String Optional. The visible part of the hidden order quantity (the only valid value is "0").
original_client_order_id String Optional. Identifier of replaced order.
created_at DateTime Date of order's creation.
updated_at DateTime Date of order's last update.
margin_mode String Margin mode.
Possible values: isolated, cross
trades []Trade Optional. List of trades. Never returned for an order list request.
price_average String Average price of executed order quantity.
margin_auto Boolean Optional. Flag indicating whether AMM (auto margin management) is enabled for the margin account or position the order belongs to. Refer to Margin Settings.

Trade model consists of:

Name Type Description
id Number Trade identifier.
quantity String Quantity of trade.
price String Trade price.
fee String Fee paid for trade.
position_id Number Position identifier of the trade.
taker Boolean Liquidity indicator.
timestamp DateTime Date of trade.

Margin Account Model

Margin Account:

[
  {
    "symbol": "ETHUSDT",
    "type": "isolated",
    "leverage": "12.00",
    "created_at": "2024-07-01T21:20:25.118Z",
    "updated_at": "2024-07-01T21:20:25.118Z",
    "currencies": [
      {
        "code": "USDT",
        "margin_balance": "0.002000000000",
        "reserved_orders": "0",
        "reserved_positions": "0"
      }
    ],
    "positions": null,
    "margin_call": false,
    "margin_auto": true,
    "amr": false
  },
  {
    "symbol": "BTCUSDT",
    "type": "isolated",
    "leverage": "12.00",
    "created_at": "2024-04-19T17:26:10.758Z",
    "updated_at": "2024-07-01T21:20:03.64Z",
    "currencies": [
      {
        "code": "USDT",
        "margin_balance": "0.097289003250",
        "reserved_orders": "0",
        "reserved_positions": "0.029557397625"
      }
    ],
    "positions": [
      {
        "id": 475421,
        "symbol": "BTCUSDT",
        "quantity": "0.00001",
        "margin_mode": "isolated",
        "price_entry": "33304.11",
        "price_margin_call": "25395.20",
        "price_liquidation": "24884.62",
        "pnl": "0",
        "created_at": "2024-04-19T17:26:10.758Z",
        "updated_at": "2024-07-01T21:20:03.64Z"
      }
    ],
    "margin_call": false,
    "margin_auto": true,
    "amr": false
  }
]

Margin Account model consists of:

Name Type Description
symbol String Symbol code.
leverage String Optional. The ratio of borrowed funds to trader's initial margin.
type String Type of margin.
Possible values: isolated, cross
created_at DateTime Date of account creation.
updated_at DateTime Date of account last update.
currencies []Currency Amount of funds on Margin Account.
positions []Position Open positions of the Margin Account.
margin_call Boolean Flag indicating the position is close to the liquidation, and increased margin may prevent it from happening.
margin_auto Boolean Flag indicating whether AMM (auto margin management) is enabled for the margin account. Refer to Margin Settings.
amr Boolean Current value of the AMR (auto margin replenishment) flag of the margin account.

Currency Model

{
  "code": "USDT",
  "margin_balance": "14.307334034514",
  "reserved_orders": "0",
  "reserved_positions": "1.183758295800"
}

Cross-margin account:

{
  "code": "USDT",
  "margin_balance": "10.961634900600",
  "reserved_orders": "0.000000000000",
  "reserved_positions": "1.136486043995",
  "margin_call_margin": "0.955583327693",
  "liquidation_margin": "0.600175240656",
  "debt_sum": "0"
}

Currency model consists of:

Name Type Description
code String Currency code.
margin_balance String The total value of funds reserved for the position.
reserved_orders String The value reserved for active orders in the position.
reserved_positions String The minimum value reserved for position's executed quantity that cannot be reduced.
margin_call_margin String The lower boundary to margin_balance minus debt.
If the margin is equal to this value, a margin call is sent.
This do not carry information that would be valuable for predicting the condition of a position, since those change after an adjusted price (mark price) changes.
liquidation_margin String The lower boundary to margin_balance minus debt.
If the margin is equal to this value, it is liquidated.
This do not carry information that would be valuable for predicting the condition of a position, since those change after an adjusted price (mark price) changes.
debt_sum String Account debt for interests (fundings), fees, and loss.

Position Model

{
  "id": 298724,
  "symbol": "BTCUSDT",
  "quantity": "-0.00100",
  "margin_mode": "isolated",
  "pnl": "0",
  "price_entry": "7933.30",
  "price_margin_call": "887772.25",
  "price_liquidation": "914625.61",
  "created_at": "2024-04-21T14:33:34.723Z",
  "updated_at": "2024-04-21T14:33:46.149Z",
  "margin_auto": true,
  "amr": false
}

Position model consists of:

Name Type Description
id String Position identifier.
symbol String Symbol code.
quantity String Position quantity.
leverage String Optional. The ratio of borrowed funds to trader's initial margin.
margin_mode String Margin mode.
Possible values: isolated, cross
pnl String Unrealized profit and loss.
fee_cumulative String Total amount of fees paid throughout the position lifetime until it is closed.
This value does zero out after the position closes and does not when it flips.
price_entry String Average weighted price of position open orders.
price_margin_call String The mark price of margin call.
price_liquidation String The mark price of force close.
created_at DateTime Position creation date and time.
updated_at DateTime Position last update date and time.
margin_auto Boolean Flag indicating whether AMM (auto margin management) is enabled for the position. Refer to Margin Settings.
amr Boolean Current value of the AMR (auto margin replenishment) flag of the position.
Margin trading option shares balances and fees with a spot account.

Get All Margin Accounts

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin/account"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.get('https://api.hitbtc.com/api/3/margin/account').json()

print(b)

Response:

[
  {
    "symbol": "BTCUSDT",
    "type": "isolated",
    "leverage": "12.00",
    "created_at": "2024-07-01T21:43:19.727Z",
    "updated_at": "2024-07-01T23:24:46.27Z",
    "currencies": [
      {
        "code": "USDT",
        "margin_balance": "0.080816916750",
        "reserved_orders": "0.000018250000",
        "reserved_positions": "0.333861705262"
      }
    ],
    "positions": [
      {
        "id": 485264,
        "symbol": "BTCUSDT",
        "quantity": "0.00001",
        "margin_mode": "isolated",
        "price_entry": "33386.18",
        "price_margin_call": "27259.95",
        "price_liquidation": "26711.87",
        "pnl": "0",
        "created_at": "2024-07-01T21:43:19.727Z",
        "updated_at": "2024-07-01T23:24:46.27Z"
      }
    ]
  },
  {
    "symbol": "ETHUSDT",
    "type": "cross",
    "leverage": "12.00",
    "created_at": "2024-07-01T21:20:25.118Z",
    "updated_at": "2024-07-01T21:20:25.118Z",
    "currencies": [
      {
        "code": "USDT",
        "margin_balance": "0.002000000000",
        "reserved_orders": "0",
        "reserved_positions": "0"
      }
    ],
    "positions": null
  }
]

GET /api/3/margin/account

Returns the user's all Margin Accounts' details.

Requires the "Orderbook, History, Trading balance" API key Access Right.

Get Isolated Margin Account

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin/account/isolated/BTCUSDT"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.get('https://api.hitbtc.com/api/3/margin/account/isolated/BTCUSDT').json()

print(b)

Response:

{
  "symbol": "BTCUSDT",
  "type": "isolated",
  "leverage": "12.00",
  "created_at": "2024-07-01T21:43:19.727Z",
  "updated_at": "2024-07-01T23:24:46.27Z",
  "currencies": [
    {
      "code": "USDT",
      "margin_balance": "0.080816916750",
      "reserved_orders": "0.000018250000",
      "reserved_positions": "0.333861705262",
      "debt_sum": "0"
    }
  ],
  "positions": null,
  "margin_call": false,
  "margin_auto": true,
  "amr": false
}

GET /api/3/margin/account/isolated/{symbol}

Returns an isolated margin account details by symbol.

Requires the "Orderbook, History, Trading balance" API key Access Right.

Get Isolated Margin Account (Opened Position)

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin/account/isolated/BTCUSDT"

Response:

{
  "symbol": "BTCUSDT",
  "type": "isolated",
  "leverage": "12.00",
  "created_at": "2024-07-01T21:43:19.727Z",
  "updated_at": "2024-07-01T23:24:46.27Z",
  "currencies": [
    {
      "code": "USDT",
      "margin_balance": "0.080816916750",
      "reserved_orders": "0.000018250000",
      "reserved_positions": "0.333861705262",
      "debt_sum": "0"
    }
  ],
  "positions": [
    {
      "id": 485264,
      "symbol": "BTCUSDT",
      "quantity": "0.00001",
      "price_entry": "33386.18",
      "price_margin_call": "27259.95",
      "price_liquidation": "26711.87",
      "pnl": "0",
      "created_at": "2024-07-01T21:43:19.727Z",
      "updated_at": "2024-07-01T23:24:46.27Z"
    }
  ],
  "margin_call": false,
  "margin_auto": true,
  "amr": false
}

Get Cross–margin Account

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin/account/cross/USDT"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.get('https://api.hitbtc.com/api/3/margin/account/cross/USDT').json()

print(b)

Response:

{
  "symbol": "BTCUSDT",
  "type": "cross",
  "created_at": "2024-07-01T21:43:19.727Z",
  "updated_at": "2024-07-01T23:24:46.27Z",
  "currencies": [
    {
      "code": "USDT",
      "margin_balance": "0.080816916750",
      "reserved_orders": "0.000018250000",
      "reserved_positions": "0.333861705262",
      "debt_sum": "0"
    }
  ],
  "positions": [
    {
      "id": 485264,
      "symbol": "BTCUSDT",
      "quantity": "0.00001",
      "leverage": "12.00",
      "margin_mode": "cross",
      "price_entry": "33386.18",
      "price_margin_call": "27259.95",
      "price_liquidation": "26711.87",
      "pnl": "0",
      "created_at": "2024-07-01T21:43:19.727Z",
      "updated_at": "2024-07-01T23:24:46.27Z"
    }
  ]
}

GET /api/3/margin/account/cross/{currency}

Returns a cross-margin account details by currency.

Requires the "Orderbook, History, Trading balance" API key Access Right.

Create/Update Margin Account

curl \
  -X PUT \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin/account/isolated/BTCUSDT" \
  -d "margin_balance=123.44"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.put('https://api.hitbtc.com/api/3/margin/account/isolated/BTCUSDT', json={"margin_balance":"123.4455", "strict_validate": True}).json()

print(b)
{
  "symbol": "BTCUSDT",
  "type": "isolated",
  "leverage": "12.00",
  "created_at": "2024-04-19T17:26:10.758Z",
  "updated_at": "2024-07-01T21:20:03.64Z",
  "currencies": [
    {
      "code": "USDT",
      "margin_balance": "0.097289003250",
      "reserved_orders": "0",
      "reserved_positions": "0.029557397625"
    }
  ],
  "positions": [
    {
      "id": 475421,
      "symbol": "BTCUSDT",
      "quantity": "0.00001",
      "price_entry": "33304.11",
      "price_margin_call": "25395.20",
      "price_liquidation": "24884.62",
      "pnl": "0",
      "created_at": "2024-04-19T17:26:10.758Z",
      "updated_at": "2024-07-01T21:20:03.64Z"
    }
  ]
}

PUT /api/3/margin/account/{margin_mode}/{instrument}

Creates or updates an isolated margin account or a cross–margin account.

Setting the margin balance to zero will lead to closing a margin account and retrieval of all formerly reserved funds to the trading account.

To withdraw all funds from the margin account send a request with margin_balance equal to "0".

Returns the created/updated Margin Account details.

Requires the "Place/cancel orders" API key Access Right.

Parameters:

Name Type Description
margin_mode String Margin mode.
Accepted values: isolated, cross
instrument String Symbol or currency code for an isolated and a cross-margin position respectively.
margin_balance Number Amount of currency. "0" to close the margin account.
strict_validate Boolean The value indicating whether the margin_balance is going to be checked for correct non-exponential format and currency precision.

Close Margin Positions

curl \
  -X DELETE \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin/position"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.delete('https://api.hitbtc.com/api/3/margin/position').json()

print(b)

DELETE /api/3/margin/position

Closes all open positions.

Returns a list of the successfully closed margin positions.

Requires the "Place/cancel orders" API key Access Right.

Close Margin Position

curl \
  -X DELETE \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin/position/isolated/BTCUSDT"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.delete('https://api.hitbtc.com/api/3/margin/position/isolated/BTCUSDT', json={"price": "9800.50", "strict_validate": True}).json()

print(b)

DELETE /api/3/margin/position/{margin_mode}/{symbol}

Closes open positions by symbol.

Requires the "Place/cancel orders" API key Access Right.

Parameters:

Name Type Description
symbol String Symbol code.
margin_mode String Margin mode.
Accepted values: isolated, cross
price Number Optional. If a price is defined, then close order would be a limit order, instead, close order would be a market order.
strict_validate Boolean Optional.
The value indicating whether the price is going to be checked for incrementation within the symbol’s tick size step. See the symbol's tick_size.
Default value: false

Get Active Margin Orders

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin/order"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.get('https://api.hitbtc.com/api/3/margin/order').json()

print(b)

Response:

[
  {
    "id": 840450210,
    "client_order_id": "c1837634ef81472a9cd13c81e7b91401",
    "symbol": "ETHBTC",
    "side": "buy",
    "status": "partiallyFilled",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "0.020",
    "price": "0.046001",
    "quantity_cumulative": "0.005",
    "post_only": false,
    "reduce_only": false,
    "margin_mode": "isolated",
    "created_at": "2024-04-12T17:17:57.437Z",
    "updated_at": "2024-04-12T17:18:08.610Z"
  }
]

GET /api/3/margin/order

Returns an array of active margin orders.

Requires the "Orderbook, History, Trading balance" API key Access Right.

Parameters:

Name Type Description
symbol String Optional. Parameter to filter active orders by symbol.

Get Active Margin Order

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin/order/c1837634ef81472a9cd13c81e7b91401"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.get('https://api.hitbtc.com/api/3/margin/order/c1837634ef81472a9cd13c81e7b91401').json()

print(b)

Response:

{
  "id": 840450210,
  "client_order_id": "c1837634ef81472a9cd13c81e7b91401",
  "symbol": "ETHBTC",
  "side": "buy",
  "status": "partiallyFilled",
  "type": "limit",
  "time_in_force": "GTC",
  "quantity": "0.020",
  "price": "0.046001",
  "quantity_cumulative": "0.005",
  "post_only": false,
  "reduce_only": false,
  "margin_mode": "isolated",
  "created_at": "2024-04-12T17:17:57.437Z",
  "updated_at": "2024-04-12T17:18:08.610Z"
}

GET /api/3/margin/order/{client_order_id}

Returns an active margin order by client_order_id.

Requires the "Orderbook, History, Trading balance" API key Access Right.

Create Margin Order

curl \
  -X POST \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin/order" \
  -d "symbol=ETHBTC&side=sell&quantity=0.063&price=0.046016"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")
orderData = {'symbol':'ETHBTC', 'side': 'sell', 'quantity': '0.063', 'price': '0.046016'}

r = session.post('https://api.hitbtc.com/api/3/margin/order', data = orderData)

print(r.json())

Response:

{
  "id": 583463871253,
  "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
  "symbol": "ETHBTC",
  "side": "sell",
  "status": "new",
  "type": "limit",
  "time_in_force": "GTC",
  "quantity": "0.063",
  "price": "0.046016",
  "quantity_cumulative": "0.000",
  "post_only": false,
  "reduce_only": false,
  "margin_mode": "isolated",
  "created_at": "2024-04-15T17:01:05.092Z",
  "updated_at": "2024-04-15T17:01:05.092Z"
}

Error response example:

{
  "error": {
    "code": 20001,
    "message": "Insufficient funds",
    "description": "Check that the funds are sufficient, given commissions"
  }
}

POST /api/3/margin/order

If AMM (auto margin management) is enabled for the order, the Margin Account and the position are created by the order itself. Otherwise, the Margin Account for the order symbol is required. Refer to Margin Settings.

Requires the "Place/cancel orders" API key Access Right.

Parameters:

Name Type Description
client_order_id String Optional. If omitted, it will be generated by the system upon order list creation. Uniqueness must be guaranteed until the last order with the same client_order_id becomes inactive (canceled, expired, or fully executed) and some time after that.
symbol String Trading symbol.
side String Trade side.
Accepted values: sell, buy
type String Optional. Order type.
Must be set to market, stopMarket, or takeProfitMarket if price was left unspecified.
Accepted values: limit, market, stopLimit, stopMarket, takeProfitLimit, takeProfitMarket
Default value: limit
time_in_force String Optional. Time in Force instruction.
Accepted values: GTC, IOC, FOK, Day, GTD
Default value:
FOK — type is market, stopMarket, takeProfitMarket;
GTC — type is limit, stopLimit, takeProfitLimit.
quantity Number Order quantity.
price Number Order price. Required if type is limit, stopLimit, or takeProfitLimit.
stop_price Number The price level that triggers order activation. Required if type is stopLimit, stopMarket, takeProfitLimit, or takeProfitMarket.
expire_time DateTime Date of order expiration. Required if time_in_force is GTD.
strict_validate Boolean Price and quantity will be checked for incrementation within the symbol’s tick size and quantity step. See the symbol's tick_size and quantity_increment.
post_only Boolean Optional. If a post-only order causes a match with a pre-existing order as a taker, then the order will expire.
reduce_only Boolean Optional. Reduce-only order, being filled, guarantees not to put the position quantity to the point when the position flips.
close_position Boolean Flag indicating a stop market order must close a margin position when executed or be canceled otherwise.
Default: false
Conditions: quantity is omitted.
display_quantity String Optional. The visible part of the hidden order quantity (the only valid value is "0").
margin_mode String Optional. Margin mode.
Accepted values: isolated, cross
Default: isolated
margin_auto Boolean Optional. Flag requesting AMM (auto margin management) for the margin account or position the order belongs to.
With AMM enabled, the margin account and the position are created by the order if they do not exist, and the required margin is reserved from the trading balance automatically. Refer to Margin Settings.
Applicable to margin orders only.
Default: false
The execution of a taker's order may be postponed for 1 millisecond.

Response: order

Create New Margin Order List

OCO request:

curl \
  -X POST \
  -H 'Content-Type: application/json' \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin/order/list" \
  -d '{
        "contingency_type": "oneCancelOther",
        "orders": [
          {
            "symbol": "ETHBTC",
            "side": "buy",
            "type": "limit",
            "time_in_force": "GTC",
            "quantity": "0.063",
            "price": "0.046016",
            "post_only": false,
            "reduce_only": false
          },
          {
            "symbol": "ETHBTC",
            "side": "sell",
            "type": "stopMarket",
            "time_in_force": "GTC",
            "quantity": "0.063",
            "stop_price": "0.044050",
            "post_only": false,
            "reduce_only": false
          }
        ]
      }'
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")
headers = {'Content-Type': 'application/json'}
orderData = '{"contingency_type": "oneCancelOther", "orders": [{"symbol": "ETHBTC", "side": "buy", "type": "limit","time_in_force": "GTC", "quantity": "0.063", "price": "0.046016", "post_only": false, "reduce_only": false}, {"symbol": "ETHBTC", "side": "sell", "type": "stopMarket", "time_in_force": "GTC", "quantity": "0.063", "stop_price": "0.044050", "post_only": false, "reduce_only": false}]}'

r = session.post('https://api.hitbtc.com/api/3/margin/order/list', data = orderData, headers=headers)

print(r.json())

OCO response:

[
  {
    "id": 840450210,
    "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
    "symbol": "ETHBTC",
    "side": "buy",
    "status": "new",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "price": "0.046016",
    "quantity_cumulative": "0.000",
    "post_only": false,
    "reduce_only": false,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneCancelOther",
    "margin_mode": "isolated",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  },
  {
    "id": 840450211,
    "client_order_id": "a53406ea49e160c63b620ca21e9fb634",
    "symbol": "ETHBTC",
    "side": "sell",
    "status": "suspended",
    "type": "stopMarket",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "stop_price": "0.044050",
    "quantity_cumulative": "0.000",
    "post_only": false,
    "reduce_only": false,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneCancelOther",
    "margin_mode": "isolated",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  }
]

OTO request:

curl \
  -X POST \
  -H 'Content-Type: application/json' \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin/order/list" \
  -d '{
        "contingency_type": "oneTriggerOther",
        "orders": [
          {
            "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
            "symbol": "ETHBTC",
            "side": "buy",
            "type": "limit",
            "time_in_force": "GTC",
            "quantity": "0.063",
            "price": "0.046016",
            "post_only": false,
            "reduce_only": false
         },
         {
            "client_order_id": "a53406ea49e160c63b620ca21e9fb634",
            "symbol": "ETHBTC",
            "side": "sell",
            "type": "stopMarket",
            "time_in_force": "GTC",
            "quantity": "0.063",
            "stop_price": "0.044050",
            "post_only": false,
            "reduce_only": false
          }
        ]
      }'
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")
headers = {'Content-Type': 'application/json'}
orderData = '{"contingency_type": "oneTriggerOther", "orders": [{"client_order_id": "d8574207d9e3b16a4a5511753eeef175", "symbol": "ETHBTC", "side": "buy", "type": "limit", "time_in_force": "GTC", "quantity": "0.063", "price": "0.046016", "post_only": false, "reduce_only": false}, {"client_order_id": "a53406ea49e160c63b620ca21e9fb634", "symbol": "ETHBTC", "side": "sell", "type": "stopMarket", "time_in_force": "GTC", "quantity": "0.063", "stop_price": "0.044050", "post_only": false, "reduce_only": false}]}'

r = session.post('https://api.hitbtc.com/api/3/margin/order/list', data = orderData, headers=headers)

print(r.json())

OTO response:

[
  {
    "id": 840450210,
    "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
    "symbol": "ETHBTC",
    "side": "buy",
    "status": "new",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "price": "0.046016",
    "quantity_cumulative": "0.063",
    "post_only": false,
    "reduce_only": false,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneTriggerOther",
    "margin_mode": "isolated",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  },
  {
    "id": 840450211,
    "client_order_id": "a53406ea49e160c63b620ca21e9fb634",
    "symbol": "ETHBTC",
    "side": "sell",
    "status": "suspended",
    "type": "stopMarket",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "quantity_cumulative": "0.057",
    "post_only": false,
    "reduce_only": false,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneTriggerOther",
    "margin_mode": "isolated",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  }
]

OTOCO request:

curl \
  -X POST \
  -H 'Content-Type: application/json' \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin/order/list" \
  -d '{
        "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
        "contingency_type": "oneTriggerOneCancelOther",
        "orders": [
            {
              "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
              "symbol": "ETHBTC",
              "side": "buy",
              "type": "limit",
              "time_in_force": "GTC",
              "quantity": "0.063",
              "price": "0.046016",
              "post_only": false,
              "reduce_only": false
            },
            {
              "client_order_id": "2723cdfba2d609b621d5d055e3ef9be2", \
              "symbol": "ETHBTC",
              "side": "sell",
              "type": "limit",
              "time_in_force": "GTC",
              "quantity": "0.063",
              "price": "0.050000",
              "post_only": false,
              "reduce_only": false
            },
            {
              "client_order_id": "a53406ea49e160c63b620ca21e9fb634",
              "symbol": "ETHBTC",
              "side": "sell",
              "type": "stopMarket",
              "time_in_force": "GTC",
              "quantity": "0.063",
              "stop_price": "0.044050",
              "post_only": false,
              "reduce_only": false
            }
        ]
      }'
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")
headers = {'Content-Type': 'application/json'}
orderData = '{"contingency_type": "oneTriggerOneCancelOther", "orders": [{"client_order_id": "d8574207d9e3b16a4a5511753eeef175", "symbol": "ETHBTC", "side": "buy", "type": "limit", "time_in_force": "GTC", "quantity": "0.063", "price": "0.046016", "post_only": false, "reduce_only": false}, {"client_order_id": "2723cdfba2d609b621d5d055e3ef9be2", "symbol": "ETHBTC", "side": "sell", "type": "limit", "time_in_force": "GTC", "quantity": "0.063", "price": "0.050000", "post_only": false, "reduce_only": false}, {"client_order_id": "a53406ea49e160c63b620ca21e9fb634", "symbol": "ETHBTC", "side": "sell", "type": "stopMarket", "time_in_force": "GTC", "quantity": "0.063", "stop_price": "0.044050", "post_only": false, "reduce_only": false}]}'

r = session.post('https://api.hitbtc.com/api/3/margin/order/list', data = orderData, headers=headers)

print(r.json())

OTOCO response:

[
  {
    "id": 840450210,
    "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
    "symbol": "ETHBTC",
    "side": "buy",
    "status": "new",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "price": "0.046016",
    "quantity_cumulative": "0.000",
    "post_only": false,
    "reduce_only": false,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneTriggerOneCancelOther",
    "margin_mode": "isolated",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  },
  {
    "id": 840450211,
    "client_order_id": "2723cdfba2d609b621d5d055e3ef9be2",
    "symbol": "ETHBTC",
    "side": "sell",
    "status": "suspended",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "price": "0.050000",
    "quantity_cumulative": "0.000",
    "post_only": false,
    "reduce_only": false,
    "inactive": true,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneTriggerOneCancelOther",
    "margin_mode": "isolated",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  },
  {
    "id": 840450211,
    "client_order_id": "a53406ea49e160c63b620ca21e9fb634",
    "symbol": "ETHBTC",
    "side": "sell",
    "status": "suspended",
    "type": "stopMarket",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "stop_price": "0.044050",
    "quantity_cumulative": "0.000",
    "post_only": false,
    "reduce_only": false,
    "inactive": true,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneTriggerOneCancelOther",
    "margin_mode": "isolated",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  }
]

Error response example:

{
  "error": {
    "code": 20001,
    "message": "Insufficient funds",
    "description": "Check that the funds are sufficient, given commissions"
  }
}

POST /api/3/margin/order/list

Creates a new margin order list.

Requires the "Place/cancel orders" API key Access Right.

Parameters:

Name Type Description
order_list_id String Order list identifier. If omitted, it will be generated by the system upon order list creation. Must be equal to client_order_id of the first order in the request.
contingency_type String Order list type.
Accepted values:
oneCancelOther (OCO) — all orders in the set should be canceled if one of them was executed;
oneTriggerOther (OTO) — execution of the first (primary) order on the list activates other (secondary) orders as independent of each other;
oneTriggerOneCancelOther (OTOCO) — the execution of the first (primary) order on the list activates the other (secondary) orders as an OCO order list.
orders []Order Orders in the list. There must be 2 or 3 orders for allOrNone/oneCancelOther/oneTriggerOther and 3 — for oneTriggerOneCancelOther. Placing any other number of orders will result in an error.

Order model consists of:

Name Type Description
client_order_id String Optional. Must be different from the identifiers of other orders in the list.
If omitted, it will be generated by the system upon order list creation. Uniqueness must be guaranteed until the last order with the same client_order_id becomes inactive (canceled, expired, or fully executed) and some time after that.
symbol String Symbol code.
Must be the same for all orders in an oneTriggerOneCancelOther order list (placing orders in different order books is not supported).
side String Trade side.
Accepted values: sell, buy
type String Optional. Order type.
Accepted values:
for oneCancelOther (and secondary orders in oneTriggerOneCancelOther) — limit, stopLimit, stopMarket, takeProfitLimit, takeProfitMarket;
for oneTriggerOneCancelOther — limit, market, stopLimit, stopMarket, takeProfitLimit, takeProfitMarket.
Default value: limit
time_in_force String Optional. Time in Force instruction.
Accepted values:
for oneCancelOther (and secondary orders in oneTriggerOneCancelOther) — GTC, IOC (except limit orders), FOK (except limit orders), Day, GTD;
for oneTriggerOneCancelOther — GTC, IOC, FOK, Day, GTD.
quantity String Order quantity.
price String Order price. Required if type is limit, stopLimit, or takeProfitLimit.
stop_price String The price level that triggers order activation. Required if type is stopLimit, stopMarket, takeProfitLimit, or takeProfitMarket.
expire_time DateTime Date of order expiration. Required if time_in_force is GTD.
strict_validate Boolean Price and quantity will be checked for incrementation within the symbol’s tick size and quantity step. See the symbol's tick_size and quantity_increment.
post_only Boolean Optional. If a post-only order causes a match with a pre-existing order as a taker, then the order will expire.
reduce_only Boolean Optional. Reduce-only order, being filled, guarantees not to put the position quantity to the point when the position flips.
close_position Boolean Flag indicating a stop market order must close a margin position when executed or be canceled otherwise.
Default: false
Conditions: quantity is omitted.
display_quantity String Optional. The visible part of the hidden order quantity (the only valid value is '0').
margin_mode String Optional. Margin mode.
Accepted values: isolated, cross
Default: isolated
margin_auto Boolean Optional. Flag requesting AMM (auto margin management) for the margin account or position the order belongs to.
With AMM enabled, the margin account and the position are created by the order if they do not exist, and the required margin is reserved from the trading balance automatically. Refer to Margin Settings.
Applicable to margin orders only.
Default: false
An OCO order list cannot include more than one limit order (the same applies to secondary orders in an OTOCO order list).

Response: array of margin orders

Replace Margin Order

curl \
  -X PATCH \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin/order/d8574207d9e3b16a4a5511753eeef174" \
  -d "quantity=0.063&price=0.046016&new_client_order_id=d8574207d9e3b16a4a5511753eeef175"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")
orderData = {'quantity': '0.063', 'price': '0.046016', 'new_client_order_id': 'd8574207d9e3b16a4a5511753eeef175' }

r = session.patch('https://api.hitbtc.com/api/3/margin/order/d8574207d9e3b16a4a5511753eeef174', data = orderData)

print(r.json())

Response:

{
  "id": 0,
  "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
  "symbol": "ETHBTC",
  "side": "sell",
  "status": "new",
  "type": "limit",
  "time_in_force": "GTC",
  "quantity": "0.063",
  "price": "0.046016",
  "quantity_cumulative": "0.000",
  "post_only": false,
  "reduce_only": false,
  "margin_mode": "isolated",
  "created_at": "2024-04-15T17:01:05.092Z",
  "updated_at": "2024-04-15T17:01:05.092Z"
}

Error response example:

{
  "error": {
    "code": 20001,
    "message": "Insufficient funds",
    "description": "Check that the funds are sufficient, given commissions"
  }
}

PATCH /api/3/margin/order/{client_order_id}

Replaces a margin order.

Requires the "Place/cancel orders" API key Access Right.

Parameters:

Name Type Description
new_client_order_id String Optional. client_order_id for a new order.
quantity Number Order quantity.
price Number Optional. Order price. Required if type is limit, stopLimit, or takeProfitLimit.
stop_price Number Optional. The price level that triggers order activation. Specified if type is stopLimit, stopMarket, takeProfitLimit, or takeProfitMarket.
strict_validate Boolean Optional. Price and quantity will be checked for incrementation within the symbol’s tick size and quantity step. See the symbol's tick_size and quantity_increment.

Response: margin order

Cancel All Margin Orders

DELETE /api/3/margin/order

Cancels all active margin orders.

Requires the "Place/cancel orders" API key Access Right.

Parameters:

Name Type Description
symbol String Optional. Parameter to filter active margin orders by symbol.

Response: array of margin orders

Cancel Margin Order

curl \
  -X DELETE \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin/order/d8574207d9e3b16a4a5511753eeef175"

Response:

{
  "id": 0,
  "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
  "symbol": "ETHBTC",
  "side": "sell",
  "status": "canceled",
  "type": "limit",
  "time_in_force": "GTC",
  "quantity": "0.000",
  "price": "0.046016",
  "quantity_cumulative": "0.000",
  "post_only": false,
  "reduce_only": false,
  "margin_mode": "isolated",
  "created_at": "2024-04-15T17:01:05.092Z",
  "updated_at": "2024-04-15T18:08:57.226Z"
}

Example of Order not found error response:

{
  "error": {
    "code": 20002,
    "message": "Order not found",
    "description": ""
  }
}

DELETE /api/3/margin/order/{client_order_id}

Cancels a margin order.

Requires the "Place/cancel orders" API key Access Right.

Response: margin order

Get Margin Position Parameters

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin/config"

Response:

{
  "config": [
    {
      "symbol": "BTCUSD",
      "margin_call_leverage_mul": "1.50",
      "liquidation_leverage_mul": "2.00",
      "max_initial_leverage": "10.00",
      "margin_mode": "Isolated",
      "force_close_fee": "0.05",
      "enabled": true,
      "active": true,
      "limit_base": "50000.00",
      "limit_power": "2.2",
      "unlimited_threshold": "10.0"
    }
  ]
}

GET /api/3/margin/config

Returns information about margin position configuration.

Requires the "Orderbook, History, Trading balance" API key Access Right.

Response:

Name Type Description
symbol String Trading symbol.
margin_call_leverage_mul String Multiplier for calculating margin call leverage.
liquidation_leverage_mul String Multiplier for calculating liquidation leverage.
max_initial_leverage String Maximum leverage that the user can use for margin trading.
margin_mode String Mode of margin trading.
Possible values: Isolated, Cross
force_close_fee String Fee for the force closing of the position.
enabled Boolean Is margin trading available.
active Boolean Are there any positions which comply with the parameters (including not yet opened).
limit_base String Optional. An absolute maximum that a position value can reach. Returns only if the risk limit exists.
limit_power String Optional. Power which determines the influence of the leverage on the risk limit value. Returns only if the risk limit exists.
unlimited_threshold String Optional. Position leverage below which the risk limit is not calculated. Returns only if the risk limit exists.

Margin Trading History

Please note that trading history may be updated with a delay up to 30 seconds, with a mean delay of around 1 second.

Margin Orders History

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin/history/order?symbol=ETHBTC"
[
  {
    "id": 828680665,
    "client_order_id": "f4307c6e507e49019907c917b6d7a084",
    "symbol": "ETHBTC",
    "side": "sell",
    "status": "partiallyFilled",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "13.942",
    "price": "0.011384",
    "price_average": "0.055487",
    "quantity_cumulative": "5.240",
    "margin_mode": "isolated",
    "created_at": "2024-04-16T14:18:47.321Z",
    "updated_at": "2024-04-19T15:23:54.876Z"
  },
  {
    "id": 828680667,
    "client_order_id": "f4307c6e507e49019907c917b6d7a084",
    "symbol": "ETHBTC",
    "side": "sell",
    "status": "partiallyFilled",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "13.942",
    "price": "0.011384",
    "price_average": "0.045000",
    "quantity_cumulative": "5.240",
    "margin_mode": "isolated",
    "created_at": "2024-04-16T14:18:50.321Z",
    "updated_at": "2024-04-19T15:23:56.876Z"
  }
]

GET /api/3/margin/history/order

Returns all margin orders. Orders without executions are deleted after 24 hours.

Requires the "Orderbook, History, Trading balance" API key Access Right.

All parameters are optional.

Parameters:

Name Type Description
client_order_id String If set, other parameters will be ignored, including limit and offset.
sort String Sort direction.
Accepted values: DESC, ASC
Default value: DESC
by String Filter type.
Accepted values: timestamp, id
Default value: id
symbol String Comma-separated symbol codes.
statuses String Optional. Filter by order status.
Comma-separated array.
Possible values: suspended, new, partiallyFilled, filled, canceled, expired,rejected`
from DateTime Interval initial value.
If sorting by timestamp is used, then DateTime; otherwise Number.
till DateTime Interval end value.
If sorting by timestamp is used, then DateTime; otherwise Number.
limit Number Default value: 100
Maximum value: 1000
offset Number Default value: 0
Maximum value: 100000

Response:

Name Type Description
id Number Unique order identifier as assigned by exchange.
client_order_id String Unique order identifier as assigned by the trader. The order history may list several orders with the same client_order_id.
symbol String Symbol code.
side String Trade side.
Possible values: sell, buy
status String Order state.
Possible values:
new — an order is placed in the order book.
suspended — a stopLimit, stopMarket, takeProfitLimit or takeProfitMarket order is parked until it meets the conditions for placement in the order book.
partiallyFilled — an order is executed, but a part of its quantity is not filled yet.
filled — order quantity filled completely.
canceled — an order is canceled. It can either be done by a user through a cancel/replace request or by the system under specific circumstances.
expired — an order is deactivated after it no longer satisfies Time in Force (IOC, FOK) or Post Only requirements.
type String Order type.
Possible values: limit, market, stopLimit, stopMarket, takeProfitLimit, takeProfitMarket
time_in_force String Time in Force is a special instruction used when placing an order to indicate how long it will remain active before it is executed or expired.
GTC — "Good-Till-Canceled" order won't be closed until it is filled.
IOC — "Immediate-Or-Cancel" order must be executed immediately. Any part of an IOC order that cannot be filled immediately will be canceled.
FOK — "Fill-Or-Kill" order must be executed immediately and completely or not executed at all.
Day — keeps the order active until the end of the trading day (23:59 UTC+0).
GTD — "Good-Till-Date" order may remain active until the time specified in expire_time.
quantity String Order quantity.
quantity_cumulative String Executed order quantity.
display_quantity String The visible part of the hidden order quantity.
price String Order price.
price_average String Average price of executed order quantity.
expire_time DateTime Date of order expiration. Specified if time_in_force is GTD.
position_id Number Optional. Position identifier of the order.
stop_price String The price level that triggers order activation. Specified if type is stopLimit, stopMarket, takeProfitLimit, or takeProfitMarket.
created_at DateTime Date of order's creation.
updated_at DateTime Date of order's last update.
order_list_id String Optional. Order list identifier.
contingency_type String Optional. Order list type.
Possible values: oneCancelOther, oneTriggerOther, oneTriggerOneCancelOther
margin_mode String Margin mode.
Possible values: isolated, cross
close_position Boolean Flag indicating a stop market order must close a margin position when executed or be canceled otherwise.
margin_auto Boolean Optional. Flag indicating whether AMM (auto margin management) is enabled for the margin account or position the order belongs to. Refer to Margin Settings.

Margin Trades History

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin/history/trade?symbol=ETHBTC"
[
  {
    "id": 9535486,
    "order_id": 816088377,
    "client_order_id": "f8dbaab336d44d5ba3ff578098a68454",
    "symbol": "ETHBTC",
    "side": "sell",
    "quantity": "0.061",
    "price": "0.045487",
    "fee": "0.000002775",
    "timestamp": "2024-04-17T12:32:57.848Z",
    "margin_mode": "isolated",
    "taker": true
  },
  {
    "id": 9535437,
    "order_id": 816088021,
    "client_order_id": "27b9bfc068b44194b1f453c7af511ed6",
    "symbol": "ETHBTC",
    "side": "buy",
    "quantity": "0.038",
    "price": "0.046000",
    "fee": "-0.000000174",
    "timestamp": "2024-04-17T12:30:57.848Z",
    "margin_mode": "isolated",
    "taker": true
  }
]

GET /api/3/margin/history/trade

Get the user's trading history.

Requires the "Orderbook, History, Trading balance" API key Access Right.

All parameters are optional.

Parameters:

Name Type Description
order_id Number Unique order identifier as assigned by exchange.
position_id Number Position identifier of the taker's order in the trade.
symbol String Comma-separated symbol codes.
sort String Sort direction.
Accepted values: DESC, ASC
Default value: DESC
by String Filter type.
Accepted values: timestamp, id
Default value: id
from DateTime or Number Interval initial value. If sorting by timestamp is used, then DateTime; otherwise Number.
till DateTime or Number Interval end value. If sorting by timestamp is used, then DateTime; otherwise Number.
limit Number Default value: 100
Maximum value: 1000
offset Number Default value: 0
Maximum value: 100000
If order_id is specified, the rest of parameters is ignored.

Response:

Name Type Description
id String Trade unique identifier as assigned by exchange.
order_id String Unique order identifier as assigned by exchange.
client_order_id String Unique order identifier as assigned by the trader. The order history may list several orders with the same client_order_id.
symbol String Trading symbol.
side String Trade side.
Possible values: sell, buy
quantity String Trade quantity.
price String Trade price.
fee String Trade commission.
Can be negative ("rebate" — reward paid to the trader). See fee currency in the symbol config.
timestamp DateTime Trade timestamp.
taker Boolean Liquidity indicator.
position_id Number Optional. Position identifier of the taker's order in the trade.
pnl String Optional. Realized Profit and Loss on this trade.
liquidation Boolean Optional. Whether it is a liquidation trade.
margin_mode String Margin mode.
Possible values: isolated, cross

Margin Positions History

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin/history/positions"
[
  {
    "id":3001,
    "entry_value": "0",
    "entry_price": "0.000",
    "avg_buy_price": "1978.057",
    "avg_sell_price": "3851.001",
    "buy_quantity": "0.0034",
    "sell_quantity": "0.0034",
    "quantity": "0",
    "margin_call_price": "0.000",
    "liquidation_price": "0.000",
    "bankruptcy_price": "0.000",
    "margin": "100.169018395350",
    "required_margin": "0",
    "orders_margin": "0.000006557500",
    "pnl": "0.187294400000",
    "leverage": "10.00",
    "margin_mode": "isolated",
    "state": "closed",
    "symbol": "ETHUSDT",
    "margin_call": false,
    "margin_auto": true,
    "amr": false,
    "create_timestamp": 1626881592397,
    "update_timestamp": 1639570624225
  }
]

GET /api/3/margin/history/positions

Get the margin positions history.

Requires the "Orderbook, History, Trading balance" API key Access Right.

Parameters:

Name Type Description
symbol String Comma-separated symbol codes.
states String Optional. Filter by position status.
Comma-separated array.
Possible values: active, closed, liquidated
sort String Optional. Sort direction.
Accepted values: DESC, ASC
Default value: DESC
from Number Optional. Interval initial value in nanoseconds. Minimum value: 1
till Number Optional. Interval end value in nanoseconds. Minimum value: 1
limit Number Optional. Default value: 100
Maximum value: 1000
offset Number Optional. Default value: 0
Maximum value: 100000
by String The name of the field to order the results by (only sorting by update_timestamp is allowed).
Accepted values: ts, timestamp

Response:

Name Type Description
id Number Position identifier.
entry_value String Position value in currency.
entry_price String Weighted average open price.
avg_buy_price String Weighted average buy price.
avg_sell_price String Weighted average sell price.
buy_quantity String Total quantity of buy trades in the position.
sell_quantity String Total quantity of sell trades in the position.
quantity String Position quantity.
margin_call_price String If the market is equal to or worse than this price, a margin call will be issued.
liquidation_price String The price at which the platform begins to close the position.
bankruptcy_price String The price at which the position can no longer be closed with any non-negative PnL.
margin String Amount of margin expressed in the quote currency.
required_margin String Margin reserved for close orders.
orders_margin String Margin reserved for open orders.
pnl String Unrealized Profit and Loss.
leverage String Position leverage.
margin_mode String Mode of margin trading.
Possible values: isolated, cross
state String Position state.
Possible values: closed, active, liquidated
fee_cumulative String Total amount of fees paid throughout the position lifetime until it is closed.
This value does zero out after the position closes and does not when it flips.
symbol String Symbol code.
margin_call Boolean Flag indicating the position is close to the liquidation, and increased margin may prevent it from happening.
margin_auto Boolean Flag indicating whether AMM (auto margin management) was enabled for the position. Refer to Margin Settings.
amr Boolean Value of the AMR (auto margin replenishment) flag of the position.
create_timestamp Number Timestamp of position creation in nanoseconds.
update_timestamp Number Timestamp of position update in nanoseconds.

Margin Clearing Details

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/margin/history/clearing"
[
  {
    "timestamp": 1646524800267,
    "position_id": 972,
    "position_quantity": "0.00010",
    "position_entry_value": "5.126379000000",
    "type": "interest",
    "symbol": "BTCUSDT",
    "currency": "USD",
    "amount": "0.011819526000",
    "rate": "0.0001",
    "debt_delta": "0"
  }
]

GET /api/3/margin/history/clearing

Get clearing details.

Requires the "Orderbook, History, Trading balance" API key Access Right.

All parameters are optional.

Parameters:

Name Type Description
currency String Quote currency code.
sort String Sort direction.
Accepted values: DESC, ASC
Default value: DESC
from Number Interval initial value in nanoseconds. Minimum value: 1
till Number Interval end value in nanoseconds. Minimum value: 1
limit Number Default value: 100
Maximum value: 1000
offset Number Default value: 0
Maximum value: 100000

Response:

Name Type Description
timestamp Number Transfer timestamp in nanoseconds.
position_id Number Optional. Position identifier.
position_quantity String Optional. Position quantity.
position_entry_value String Optional. Position value in currency.
type String Transfer type.
Possible values: interest
symbol String Optional. Symbol code.
currency String Transfer currency.
amount Number Transfer amount.
rate String Optional. Interest rate. It is null if the withdrawal occurred during a close trade (debt collection).
trade_id Number Optional. Trade identifier. Applicable if the withdrawal occurred during a close trade (debt collection).
debt_delta String Optional. Debt value. Returned if a user was unable to pay interest during the last withdrawal but had a positive UPnL.

Futures Trading

Futures Order Model

Futures Order:

{
  {
    "id": 828680665,
    "client_order_id": "f4307c6e507e49019907c917b6d7a084",
    "symbol": "BTCUSDT_PERP",
    "side": "sell",
    "status": "partiallyFilled",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "13.942",
    "price": "0.011384",
    "quantity_cumulative": "5.240",
    "created_at": "2024-04-16T14:18:47.321Z",
    "updated_at": "2024-04-16T14:18:47.321Z",
    "post_only": false,
    "display_quantity": "0",
    "margin_mode": "isolated",
    "margin_auto": true,
    "price_average": "0.011384",
    "trades": [
      {
        "id": 1361171432,
        "position_id": 123,
        "quantity": "5.240",
        "price": "0.011384",
        "fee": "0.001237803000",
        "taker": true,
        "timestamp": "2024-04-16T14:18:47.321Z"
      }
    ]
  }
}

Margin order model consists of:

Name Type Description
id Number Unique order identifier as assigned by exchange.
client_order_id String Unique order identifier as assigned by the trader. Uniqueness must be guaranteed until the last order with the same client_order_id becomes inactive (canceled, expired, or fully executed) and some time after that.
order_list_id String Optional. Order list identifier.
contingency_type String Optional. Order list type.
Possible values:
allOrNone, oneCancelOther, oneTriggerOneCancelOther
symbol String Contract code.
side String Trade side.
Possible values: sell, buy
status String Order state.
Possible values:
new — an order is placed in the order book.
suspended — a stopLimit, stopMarket, takeProfitLimit or takeProfitMarket order is parked until it meets the conditions for placement in the order book.
partiallyFilled — an order is executed, but a part of its quantity is not filled yet.
filled — order quantity filled completely.
canceled — an order is canceled. It can either be done by a user through a cancel/replace request or by the system under specific circumstances.
expired — an order is deactivated after it no longer satisfies Time in Force (IOC, FOK) or Post Only requirements.
type String Order type.
Possible values: limit, market, stopLimit, stopMarket, takeProfitLimit, takeProfitMarket
time_in_force String Time in Force is a special instruction used when placing an order to indicate how long it will remain active before it is executed or expired.
GTC — "Good-Till-Canceled" order won't be closed until it is filled.
IOC — "Immediate-Or-Cancel" order must be executed immediately. Any part of an IOC order that cannot be filled immediately will be canceled.
FOK — "Fill-Or-Kill" order must be executed immediately and completely or not executed at all.
Day — keeps the order active until the end of the trading day (23:59 UTC+0).
GTD — "Good-Till-Date" order may remain active until the time specified in expire_time.
quantity String Order quantity.
quantity_cumulative String Executed order quantity.
price String Optional. Order price.
stop_price String Optional. The price level that triggers order activation. Specified if type is stopLimit, stopMarket, takeProfitLimit, or takeProfitMarket.
expire_time DateTime Optional. Date of order expiration. Specified if time_in_force is GTD.
post_only Boolean A post-only order is an order that does not remove liquidity. If a post-only order causes a match with a pre-existing order as a taker, then the order will expire.
reduce_only Boolean Reduce-only order, being filled, guarantees not to put the position quantity to the point when the position flips.
close_position Boolean Flag indicating a stop market order must close a margin position when executed or be canceled otherwise.
Default: false
Conditions: quantity is omitted.
display_quantity String Optional. The visible part of the hidden order quantity (the only valid value is "0").
original_client_order_id String Optional. Identifier of replaced order.
created_at DateTime Date of order's creation.
updated_at DateTime Date of order's last update.
margin_mode String Margin mode.
Possible values: isolated, cross
trades []Trade Optional. List of trades. Never returned for an order list request.
price_average String Average price of executed order quantity.
margin_auto Boolean Optional. Flag indicating whether AMM (auto margin management) is enabled for the margin account or position the order belongs to. Refer to Margin Settings.

Trade model consists of:

Name Type Description
id Number Trade identifier.
quantity String Quantity of trade.
price String Trade price.
fee String Fee paid for trade.
position_id Number Position identifier of the trade.
taker Boolean Liquidity indicator.
timestamp DateTime Date of trade.

Futures Margin Account Model

Futures Margin Account:

[
  {
    "symbol": "ETHUSDT_PERP",
    "type": "isolated",
    "leverage": "12.00",
    "created_at": "2024-07-01T21:20:25.118Z",
    "updated_at": "2024-07-01T21:20:25.118Z",
    "currencies": [
      {
        "code": "USDT",
        "margin_balance": "0.002000000000",
        "reserved_orders": "0",
        "reserved_positions": "0"
      }
    ],
    "positions": null,
    "margin_call": false,
    "margin_auto": true,
    "amr": false
  },
  {
    "symbol": "BTCUSDT_PERP",
    "type": "isolated",
    "leverage": "12.00",
    "created_at": "2024-04-19T17:26:10.758Z",
    "updated_at": "2024-07-01T21:20:03.64Z",
    "currencies": [
      {
        "code": "USDT",
        "margin_balance": "0.097289003250",
        "reserved_orders": "0",
        "reserved_positions": "0.029557397625"
      }
    ],
    "positions": [
      {
        "id": 475421,
        "symbol": "BTCUSDT_PERP",
        "quantity": "0.00001",
        "margin_mode": "isolated",
        "price_entry": "33304.11",
        "price_margin_call": "25395.20",
        "price_liquidation": "24884.62",
        "pnl": "0",
        "created_at": "2024-04-19T17:26:10.758Z",
        "updated_at": "2024-07-01T21:20:03.64Z"
      }
    ],
    "margin_call": false,
    "margin_auto": true,
    "amr": false
  }
]

Margin Account model consists of:

Name Type Description
symbol String Contract code.
leverage String Optional. The ratio of borrowed funds to trader's initial margin.
type String Type of margin.
Possible values: isolated, cross
created_at DateTime Date of account creation.
updated_at DateTime Date of account last update.
currencies []Currency Amount of funds on Margin Account.
positions []Position Optional. Open positions of the Margin Account.
margin_call Boolean Flag indicating the position is close to the liquidation, and increased margin may prevent it from happening.
margin_auto Boolean Flag indicating whether AMM (auto margin management) is enabled for the margin account. Refer to Margin Settings.
amr Boolean Current value of the AMR (auto margin replenishment) flag of the margin account.

Currency Model

Isolated margin account

{
  "code": "USDT",
  "margin_balance": "14.307334034514",
  "reserved_orders": "0",
  "reserved_positions": "1.183758295800"
}

Cross-margin account:

{
  "code": "USDT",
  "margin_balance": "10.961634900600",
  "reserved_orders": "0.000000000000",
  "reserved_positions": "1.136486043995",
  "margin_call_margin": "0.955583327693",
  "liquidation_margin": "0.600175240656",
  "debt_sum": "0"
}

Currency model consists of:

Name Type Description
code String Currency code.
margin_balance String The total value of funds reserved for the position.
reserved_orders String The value reserved for active orders in the position.
reserved_positions String The minimum value reserved for position's executed quantity that cannot be reduced.
margin_call_margin String The lower boundary to margin_balance minus debt.
If the margin is equal to this value, a margin call is sent.
This do not carry information that would be valuable for predicting the condition of a position, since those change after an adjusted price (mark price) changes.
liquidation_margin String The lower boundary to margin_balance minus debt.
If the margin is equal to this value, it is liquidated.
This do not carry information that would be valuable for predicting the condition of a position, since those change after an adjusted price (mark price) changes.
debt_sum String Account debt for interests (fundings), fees, and loss.

Position Model

{
  "id": 298724,
  "symbol": "BTCUSDT_PERP",
  "quantity": "-0.00100",
  "leverage": "12.00",
  "margin_mode": "isolated",
  "pnl": "0",
  "price_entry": "7933.30",
  "price_margin_call": "887772.25",
  "price_liquidation": "914625.61",
  "created_at": "2024-04-21T14:33:34.723Z",
  "updated_at": "2024-04-21T14:33:46.149Z",
  "margin_auto": true,
  "amr": false
}

Position model consists of:

Name Type Description
id String Position identifier.
symbol String Contract code.
quantity String Position quantity.
leverage String The ratio of borrowed funds to trader's initial margin.
margin_mode String Margin mode.
Possible values: isolated, cross
pnl String Unrealized profit and loss.
fee_cumulative String Total amount of fees paid throughout the position lifetime until it is closed.
This value does zero out after the position closes and does not when it flips.
price_entry String Average weighted price of position open orders.
price_margin_call String The mark price of margin call.
price_liquidation String The mark price of force close.
created_at DateTime Position creation date and time.
updated_at DateTime Position last update date and time.
margin_auto Boolean Flag indicating whether AMM (auto margin management) is enabled for the position. Refer to Margin Settings.
amr Boolean Current value of the AMR (auto margin replenishment) flag of the position.

Get Trading Balance

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/futures/balance"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.get('https://api.hitbtc.com/api/3/futures/balance').json()

print(b)

Response. All currencies:

[
  {
    "currency": "ETH",
    "available": "10.000000000",
    "reserved": "0.56",
    "reserved_margin": "0",
    "cross_margin_reserved": "0"
  },
  {
    "currency": "BTC",
    "available": "0.010205869",
    "reserved": "0",
    "reserved_margin": "0",
    "cross_margin_reserved": "0"
  }
]

Response. One currency:

{
  "available": "10.000000000",
  "reserved": "0.56",
  "reserved_margin": "0",
  "cross_margin_reserved": "0"
}

GET /api/3/futures/balance GET /api/3/futures/balance/{currency}

Returns the user's trading balance.

Requires the "Orderbook, History, Trading balance" API key Access Right.

Parameters:

Name Type Description
currency String Optional. Currency filter.

Response:

Name Type Description
currency String Currency code.
available String Amount available for trading or transfer to wallet.
reserved String Total amount reserved for active orders, incomplete transfers to wallet, and margin trading.
reserved_margin String Amount reserved for margin trading funded by an isolated margin account.
cross_margin_reserved String Amount reserved for margin trading funded by a cross–margin account.

Get Futures Margin Accounts

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/futures/account"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.get('https://api.hitbtc.com/api/3/futures/account').json()

print(b)

Response:

[
  {
    "symbol": "BTCUSDT_PERP",
    "type": "isolated",
    "leverage": "12.00",
    "created_at": "2024-07-01T21:43:19.727Z",
    "updated_at": "2024-07-01T23:24:46.27Z",
    "currencies": [
      {
        "code": "USDT",
        "margin_balance": "0.080816916750",
        "reserved_orders": "0.000018250000",
        "reserved_positions": "0.333861705262"
      }
    ],
    "positions": [
      {
        "id": 485264,
        "symbol": "BTCUSDT_PERP",
        "quantity": "0.00001",
        "margin_mode": "isolated",
        "price_entry": "33386.18",
        "price_margin_call": "27259.95",
        "price_liquidation": "26711.87",
        "pnl": "0",
        "created_at": "2024-07-01T21:43:19.727Z",
        "updated_at": "2024-07-01T23:24:46.27Z"
      }
    ]
  }
]

GET /api/3/futures/account

Returns all user's Futures Margin Accounts.

Requires the "Orderbook, History, Trading balance" API key Access Right.

Get Futures Margin Account

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/futures/account/isolated/BTCUSDT_PERP"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.get('https://api.hitbtc.com/api/3/futures/account/isolated/BTCUSDT_PERP').json()

print(b)

GET /api/3/futures/account/isolated/{symbol}

Returns Futures Margin Account details by symbol.

A full margin model description can be found in the "Margin Account Model" section.

Requires the "Orderbook, History, Trading balance" API key Access Right.

Get Futures Cross–margin Account

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/futures/account/cross/USDT"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.get('https://api.hitbtc.com/api/3/futures/account/cross/USDT').json()

print(b)

Response:

{
  "symbol": "BTCUSDT_PERP",
  "type": "cross",
  "created_at": "2024-07-01T21:43:19.727Z",
  "updated_at": "2024-07-01T23:24:46.27Z",
  "currencies": [
    {
      "code": "USDT",
      "margin_balance": "0.080816916750",
      "reserved_orders": "0.000018250000",
      "reserved_positions": "0.333861705262"
    }
  ],
  "positions": [
    {
      "id": 485264,
      "symbol": "BTCUSDT_PERP",
      "quantity": "0.00001",
      "leverage": "12.00",
      "margin_mode": "cross",
      "price_entry": "33386.18",
      "price_margin_call": "27259.95",
      "price_liquidation": "26711.87",
      "pnl": "0",
      "created_at": "2024-07-01T21:43:19.727Z",
      "updated_at": "2024-07-01T23:24:46.27Z"
    }
  ]
}

GET /api/3/futures/account/cross/{currency}

Returns a cross-margin account details by currency.

Requires the "Orderbook, History, Trading balance" API key Access Right.

Create/Update Margin Account

curl \
  -X PUT \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/futures/account/isolated/BTCUSDT_PERP" \
  -d "margin_balance=123.44&leverage=100"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.put('https://api.hitbtc.com/api/3/futures/account/isolated/BTCUSDT_PERP', json={"margin_balance":"123.4455", "leverage": "100", "strict_validate": True}).json()
print(b)

Response:

{
  "symbol": "BTCUSDT_PERP",
  "type": "isolated",
  "leverage": "100.00",
  "created_at": "2024-07-01T21:43:19.727Z",
  "updated_at": "2024-07-01T23:24:46.27Z",
  "currencies": [
  {
    "code": "USDT",
    "margin_balance": "123.4455",
    "reserved_orders": "0",
    "reserved_positions": "0"
  }
  ],
  "positions": null
}

PUT /api/3/futures/account/{margin_mode}/{symbol}

Creates or updates a margin account. Setting margin balance to zero will lead to closing the margin account and retrieval all formerly reserved funds to the trading account.

Returns margin account details.

To withdraw all funds from the margin account send a request with margin_balance equal to "0".

If margin_mode is "cross", specifying leverage is not allowed.

For changing the leverage POST /api/3/margin/position/leverage call is suggested.

Requires the "Place/cancel orders" API key Access Right.

Parameters:

Name Type Description
margin_mode String Margin mode.
Accepted values: isolated, cross
margin_balance Number Amount of currency reserved.
leverage Number Optional. User leverage.
Required if the balance of the isolated margin account is equal to zero.
Minimum value: "1"
Maximum value: "1000"
strict_validate Boolean Optional. The value indicating whether the margin_balance is going to be checked for correct non-exponential format and currency precision.

Set Position Leverage

curl \
  -X POST -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/futures/position/leverage" \
  -d "symbol=BTCUSDT_PERP&leverage=100&margin_mode=isolated"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.put('https://api.hitbtc.com/api/3/futures/position/leverage',
                json={"symbol": "BTCUSDT_PERP", "leverage": "100", "strict_validate": True, "margin_mode": "isolated"}).json()

print(b)

Response:

{
  "id": 11267,
  "symbol": "BTCUSDTF0",
  "margin_mode": "Isolated",
  "leverage": "12.00",
  "quantity": "0",
  "price_entry": "0",
  "price_margin_call": "0",
  "price_liquidation": "0",
  "pnl": "0",
  "fee_cumulative": "0",
  "created_at": "2024-12-06T07:53:35.67Z",
  "updated_at": "2024-12-11T00:19:51.893Z",
  "status": "normal",
  "required_margin": "0",
  "orders_margin": "0",
  "sum_fundings": "0",
  "adl_ranking": "0",
  "currency": "USDT",
  "report_reason": "leverageChanged"
}

POST /api/3/futures/position/leverage

Sets the position leverage.

Requires the "Place/cancel orders" API key Access Right.

Parameters:

Name Type Description
symbol String Contract code.
margin_mode String Margin mode.
Accepted values: isolated, cross
leverage Number User leverage.
Required if the balance of the isolated margin account is equal to zero.
Minimum value: "1"
Maximum value: "1000"
strict_validate Boolean Optional. The value indicating whether the margin_balance is going to be checked for correct non-exponential format and currency precision.

Response:

Name Type Description
id Number Position identifier.
symbol String Contract code.
margin_mode String Margin mode.
Possible values: isolated, cross
leverage String Position leverage.
quantity String Position quantity.
price_entry String Average weighted price of position open orders.
price_margin_call String The mark price of margin call.
price_liquidation String The mark price of force close.
pnl String Unrealized Profit and Loss.
fee_cumulative String Optional. Total amount of fees paid throughout the position lifetime until it is closed.
This value does zero out after the position closes and does not when it flips.
created_at DateTime Position creation date and time.
updated_at DateTime Position last update date and time.
status String Position status.
Possible values: normal, blocked, closeOnly
required_margin String Margin reserved for close orders.
orders_margin String Margin reserved for open orders.
sum_fundings String Optional. Sum of all settled funding to a position.
adl_ranking String Optional. Rank of a position which defines how appropriate a position is to be used for closing bankrupt positions avoided liquidation.
The rank represents the probability of a position becoming deleveraged: a high rank value signifies a high probability, and vice versa.
Possible values: 0 – 4
margin_call Boolean Optional. Flag indicating the position is close to the liquidation, and increased margin may prevent it from happening.
margin_auto Boolean Flag indicating whether AMM (auto margin management) is enabled for the position. Refer to Margin Settings.
amr Boolean Current value of the AMR (auto margin replenishment) flag of the position.
currency String Currency code.
report_reason String Position execution type.
Possible values: created, openTrade, closeTrade, flipTrade, updated, marginChanged, closed, status, liquidated, interestTaken, liquidationTrade, fundingTaken, deleveraged, deleverageTrade, leverageChanged, amrChanged

report_reason field may have the following values:

Name Description
created New position has been created as a result of the first set margin request.
openTrade Opening trade has been executed.
closeTrade Closing trade has been executed.
flipTrade Position has been flipped as a result of an opposite order execution with quantity exceeding the position quantity.
updated Position has been changed as a result of either order placing, canceling, position status changing, or a "margin call".
marginChanged Position margin has been added or withdrawn as a result of any subsequent set margin request (refer to created).
closed Position quantity has zeroed as a result of a close trade.
status Response to a position request.
liquidated Position has been closed as a result of a liquidation trade (including one during auto-deleveraging).
interestTaken Interest rate has been paid.
liquidationTrade Liquidation order has been placed.
fundingTaken Funding has been paid/taken.
deleveraged Position has been deleveraged.
deleverageTrade A part of position quantity has been deleveraged.
leverageChanged Leverage of a futures position has been changed.
amrChanged The value of the AMR (auto margin replenishment) flag has changed.

Close All Futures Margin Positions

curl \
  -X DELETE \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/futures/position"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.delete('https://api.hitbtc.com/api/3/futures/position').json()

print(b)

DELETE /api/3/futures/position

Closes all open positions.

Returns a list of the successfully closed margin positions.

Requires the "Place/cancel orders" API key Access Right.

Close Futures Margin Position

curl \
  -X DELETE \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/futures/position/isolated/BTCUSDT_PERP"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.delete('https://api.hitbtc.com/api/3/futures/position/isolated/BTCUSDT_PERP', json={"price": "9800.50", "strict_validate": True}).json()
print(b)

DELETE /api/3/futures/position/{margin_mode}/{symbol}

Closes open position by contract.

Returns a list of the successfully closed margin positions.

Requires the "Place/cancel orders" API key Access Right.

Parameters:

Name Type Description
symbol String Contract code.
margin_mode String Margin mode.
Accepted values: isolated, cross
price Number Optional. If a price is defined, then close order would be a limit order with the specified price, instead, close order would be a market order with the market price.
strict_validate Boolean Optional. The value indicating whether the price is going to be checked for incrementation within the symbol’s tick size step. See the symbol's tick_size.
Default value: false

Get Active Futures Orders

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/futures/order"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.get('https://api.hitbtc.com/api/3/futures/order').json()

print(b)

Response:

[
  {
    "id": 840450210,
    "client_order_id": "c1837634ef81472a9cd13c81e7b91401",
    "symbol": "ETHBTC_PERP",
    "side": "buy",
    "status": "partiallyFilled",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "0.020",
    "price": "0.046001",
    "quantity_cumulative": "0.005",
    "post_only": false,
    "reduce_only": false,
    "margin_mode": "isolated",
    "created_at": "2024-04-12T16:16:30.430Z",
    "updated_at": "2024-04-12T16:17:15.620Z"
  }
]

GET /api/3/futures/order

Returns an array of active futures orders.

A full order description can be found in the "Margin Order Model" section.

Requires the "Orderbook, History, Trading balance" API key Access Right.

Parameters:

Name Type Description
symbol String Optional. Contract code.

Response: array of orders

Get Active Futures Order

curl \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/futures/order/c1837634ef81472a9cd13c81e7b91401"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")

b = session.get('https://api.hitbtc.com/api/3/futures/order/c1837634ef81472a9cd13c81e7b91401').json()

print(b)

Response:

{
  "id": 840450210,
  "client_order_id": "c1837634ef81472a9cd13c81e7b91401",
  "symbol": "ETHBTC_PERP",
  "side": "buy",
  "status": "partiallyFilled",
  "type": "limit",
  "time_in_force": "GTC",
  "quantity": "0.020",
  "price": "0.046001",
  "quantity_cumulative": "0.005",
  "post_only": false,
  "reduce_only": false,
  "margin_mode": "isolated",
  "created_at": "2024-04-12T16:16:30.430Z",
  "updated_at": "2024-04-12T16:17:15.620Z"
}

GET /api/3/futures/order/{client_order_id}

Returns an active order by client_order_id.

Requires the "Orderbook, History, Trading balance" API key Access Right.

Create Futures Order

curl \
  -X POST \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/futures/order" \
  -d "symbol=ETHBTC_PERP&side=sell&quantity=0.063&price=0.046016"
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")
orderData = {'symbol':'ETHBTC_PERP', 'side': 'sell', 'quantity': '0.063', 'price': '0.046016' }

r = session.post('https://api.hitbtc.com/api/3/futures/order', data = orderData)

print(r.json())

Response:

{
  "id": 0,
  "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
  "symbol": "ETHBTC_PERP",
  "side": "sell",
  "status": "new",
  "type": "limit",
  "time_in_force": "GTC",
  "quantity": "0.063",
  "price": "0.046016",
  "quantity_cumulative": "0.000",
  "post_only": false,
  "reduce_only": false,
  "margin_mode": "isolated",
  "created_at": "2024-04-15T17:01:05.092Z",
  "updated_at": "2024-04-15T17:01:05.092Z"
}

Error response example:

{
  "error": {
    "code": 20001,
    "message": "Insufficient funds",
    "description": "Check that the funds are sufficient, given commissions"
  }
}

POST /api/3/futures/order

Creates a new futures order.

A full order description can be found in the "Margin Order Model" subsection.

If AMM (auto margin management) is enabled for the order, the Margin Account and the position are created by the order itself. Otherwise, the Margin Account for the order contract is required. Refer to Margin Settings.

Requires the "Place/cancel orders" API key Access Right.

Parameters:

Name Type Description
client_order_id String Optional. If omitted, an order will be created, and it will be generated by the Server. Uniqueness must be guaranteed until the last order with the same client_order_id becomes inactive (canceled, expired, or fully executed) and some time after that.
Must be from 8 to 32 characters long. May include Latin letters of any case, digits, and _, -.
If specified and corresponds to an existing order, a request will be rejected.
symbol String Contract code.
side String Trade side.
Possible values: sell, buy
type String Optional. Order type.
Possible values: limit, market, stopLimit, stopMarket, takeProfitLimit, takeProfitMarket
Default value: limit
time_in_force String Optional. Time in Force instruction.
Possible values: GTC, IOC, FOK, Day, GTD
Default value:
FOK — type is market, stopMarket, takeProfitMarket;
GTC — type is limit, stopLimit, takeProfitLimit.
quantity Number Order quantity.
price Number Order price. Required if type is limit, stopLimit, or takeProfitLimit.
stop_price Number The price level that triggers order activation. Required if type is stopLimit, stopMarket, takeProfitLimit, takeProfitMarket.
expire_time DateTime Date of order expiration. Required if time_in_force is GTD.
strict_validate Boolean Price and quantity will be checked for incrementation within the symbol’s tick size and quantity step. See the symbol's tick_size and quantity_increment.
post_only Boolean Optional. If a post-only order causes a match with a pre-existing order as a taker, then the order will expire.
reduce_only Boolean Optional. Reduce-only order, being filled, guarantees not to put the position quantity to the point when the position flips.
display_quantity String Optional. The visible part of the hidden order quantity (the only valid value is "0").
margin_mode String Optional. Margin mode.
Accepted values: isolated, cross
Default: isolated
margin_auto Boolean Optional. Flag requesting AMM (auto margin management) for the margin account or position the order belongs to.
With AMM enabled, the margin account and the position are created by the order if they do not exist, and the required margin is reserved from the trading balance automatically. Refer to Margin Settings.
Applicable to margin orders only.
Default: false
close_position Boolean Flag indicating a stop market order must close a margin position when executed or be canceled otherwise.
Default: false
Conditions: quantity is omitted.
The execution of a taker's order may be postponed for 1 millisecond.

Response: futures order

Create New Futures Order List

OCO request:

curl \
  -X POST \
  -H 'Content-Type: application/json' \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/futures/order/list" \
  -d '{
        "contingency_type": "oneCancelOther",
        "orders": [
          {
            "symbol": "ETHBTC_PERP",
            "side": "buy",
            "type": "limit",
            "time_in_force": "GTC",
            "quantity": "0.063",
            "price": "0.046016",
            "post_only": false,
            "reduce_only": false
          },
          {
            "symbol": "ETHBTC_PERP",
            "side": "sell",
            "type": "stopMarket",
            "time_in_force": "GTC",
            "quantity": "0.063",
            "stop_price": "0.044050",
            "post_only": false,
            "reduce_only": false
          }
        ]
      }'
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")
headers = {'Content-Type': 'application/json'}
orderData = '{"contingency_type": "oneCancelOther", "orders": [{"symbol": "ETHBTC_PERP", "side": "buy", "type": "limit","time_in_force": "GTC", "quantity": "0.063", "price": "0.046016", "post_only": false, "reduce_only": false}, {"symbol": "ETHBTC_PERP", "side": "sell", "type": "stopMarket", "time_in_force": "GTC", "quantity": "0.063", "stop_price": "0.044050", "post_only": false, "reduce_only": false}]}'

r = session.post('https://api.hitbtc.com/api/3/futures/order/list', data = orderData, headers=headers)

print(r.json())

OCO response:

[
  {
    "id": 840450210,
    "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
    "symbol": "ETHBTC_PERP",
    "side": "buy",
    "status": "new",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "price": "0.046016",
    "quantity_cumulative": "0.000",
    "post_only": false,
    "reduce_only": false,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneCancelOther",
    "margin_mode": "isolated",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  },
  {
    "id": 840450211,
    "client_order_id": "a53406ea49e160c63b620ca21e9fb634",
    "symbol": "ETHBTC_PERP",
    "side": "sell",
    "status": "suspended",
    "type": "stopMarket",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "stop_price": "0.044050",
    "quantity_cumulative": "0.000",
    "post_only": false,
    "reduce_only": false,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneCancelOther",
    "margin_mode": "isolated",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  }
]

OTO request:

curl \
  -X POST \
  -H 'Content-Type: application/json' \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/futures/order/list" \
  -d '{
        "contingency_type": "oneTriggerOther",
        "orders": [
          {
            "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
            "symbol": "ETHBTC_PERP",
            "side": "buy",
            "type": "limit",
            "time_in_force": "GTC",
            "quantity": "0.063",
            "price": "0.046016",
            "post_only": false,
            "reduce_only": false
          },
          {
            "client_order_id": "a53406ea49e160c63b620ca21e9fb634",
            "symbol": "ETHBTC_PERP",
            "side": "sell",
            "type": "stopMarket",
            "time_in_force": "GTC",
            "quantity": "0.063",
            "stop_price": "0.044050",
            "post_only": false,
            "reduce_only": false
          }
        ]
      }'
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")
headers = {'Content-Type': 'application/json'}
orderData = '{"contingency_type": "oneTriggerOther", "orders": [{"client_order_id": "d8574207d9e3b16a4a5511753eeef175", "symbol": "ETHBTC_PERP", "side": "buy", "type": "limit", "time_in_force": "GTC", "quantity": "0.063", "price": "0.046016", "post_only": false, "reduce_only": false}, {"client_order_id": "a53406ea49e160c63b620ca21e9fb634", "symbol": "ETHBTC_PERP", "side": "sell", "type": "stopMarket", "time_in_force": "GTC", "quantity": "0.063", "stop_price": "0.044050", "post_only": false, "reduce_only": false}]}'

r = session.post('https://api.hitbtc.com/api/3/futures/order/list', data = orderData, headers=headers)

print(r.json())

OTO response:

[
  {
    "id": 840450210,
    "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
    "symbol": "ETHBTC_PERP",
    "side": "buy",
    "status": "new",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "price": "0.046016",
    "quantity_cumulative": "0.063",
    "post_only": false,
    "reduce_only": false,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneTriggerOther",
    "margin_mode": "isolated",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  },
  {
    "id": 840450211,
    "client_order_id": "a53406ea49e160c63b620ca21e9fb634",
    "symbol": "ETHBTC_PERP",
    "side": "sell",
    "status": "suspended",
    "type": "stopMarket",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "quantity_cumulative": "0.057",
    "post_only": false,
    "reduce_only": false,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneTriggerOther",
    "margin_mode": "isolated",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  }
]

OTOCO request:

curl \
  -X POST \
  -H 'Content-Type: application/json' \
  -u "apiKey:secretKey" \
  "https://api.hitbtc.com/api/3/futures/order/list" \
  -d '{
        "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
        "contingency_type": "oneTriggerOneCancelOther",
        "orders": [
          {
            "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
            "symbol": "ETHBTC_PERP",
            "side": "buy",
            "type": "limit",
            "time_in_force": "GTC",
            "quantity": "0.063",
            "price": "0.046016",
            "post_only": false,
            "reduce_only": false
          },
          {
            "client_order_id": "2723cdfba2d609b621d5d055e3ef9be2",
            "symbol": "ETHBTC_PERP",
            "side": "sell",
            "type": "limit",
            "time_in_force": "GTC",
            "quantity": "0.063",
            "price": "0.050000",
            "post_only": false,
            "reduce_only": false
          },
          {
            "client_order_id": "a53406ea49e160c63b620ca21e9fb634",
            "symbol": "ETHBTC_PERP",
            "side": "sell",
            "type": "stopMarket",
            "time_in_force": "GTC",
            "quantity": "0.063",
            "stop_price": "0.044050",
            "post_only": false,
            "reduce_only": false
          }
        ]
      }'
import requests


session = requests.session()
session.auth = ("apiKey", "secretKey")
headers = {'Content-Type': 'application/json'}
orderData = '{"contingency_type": "oneTriggerOneCancelOther", "orders": [{"client_order_id": "d8574207d9e3b16a4a5511753eeef175", "symbol": "ETHBTC_PERP", "side": "buy", "type": "limit", "time_in_force": "GTC", "quantity": "0.063", "price": "0.046016", "post_only": false, "reduce_only": false}, {"client_order_id": "2723cdfba2d609b621d5d055e3ef9be2", "symbol": "ETHBTC_PERP", "side": "sell", "type": "limit", "time_in_force": "GTC", "quantity": "0.063", "price": "0.050000", "post_only": false, "reduce_only": false}, {"client_order_id": "a53406ea49e160c63b620ca21e9fb634", "symbol": "ETHBTC_PERP", "side": "sell", "type": "stopMarket", "time_in_force": "GTC", "quantity": "0.063", "stop_price": "0.044050", "post_only": false, "reduce_only": false}]}'

r = session.post('https://api.hitbtc.com/api/3/futures/order/list', data = orderData, headers=headers)

print(r.json())

OTOCO response:

[
  {
    "id": 840450210,
    "client_order_id": "d8574207d9e3b16a4a5511753eeef175",
    "symbol": "ETHBTC_PERP",
    "side": "buy",
    "status": "new",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "price": "0.046016",
    "quantity_cumulative": "0.000",
    "post_only": false,
    "reduce_only": false,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneTriggerOneCancelOther",
    "margin_mode": "isolated",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  },
  {
    "id": 840450211,
    "client_order_id": "2723cdfba2d609b621d5d055e3ef9be2",
    "symbol": "ETHBTC_PERP",
    "side": "sell",
    "status": "suspended",
    "type": "limit",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "price": "0.050000",
    "quantity_cumulative": "0.000",
    "post_only": false,
    "reduce_only": false,
    "inactive": true,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneTriggerOneCancelOther",
    "margin_mode": "isolated",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  },
  {
    "id": 840450211,
    "client_order_id": "a53406ea49e160c63b620ca21e9fb634",
    "symbol": "ETHBTC_PERP",
    "side": "sell",
    "status": "suspended",
    "type": "stopMarket",
    "time_in_force": "GTC",
    "quantity": "0.063",
    "stop_price": "0.044050",
    "quantity_cumulative": "0.000",
    "post_only": false,
    "reduce_only": false,
    "inactive": true,
    "order_list_id": "d8574207d9e3b16a4a5511753eeef175",
    "contingency_type": "oneTriggerOneCancelOther",
    "margin_mode": "isolated",
    "created_at": "2024-04-15T17:01:05.092Z",
    "updated_at": "2024-04-15T17:01:05.092Z"
  }
]

Error response example:

{
  "error": {
    "code": 20001,
    "message": "Insufficient funds",
    "description": "Check that the funds are sufficient, given commissions"
  }
}

POST /api/3/futures/order/list

Creates a new futures order list.

Requires the "Place/cancel orders" API key Access Right.

Parameters:

Name Type Description
order_list_id String Order list identifier. If omitted, it will be generated by the system upon order list creation. Must be equal to client_order_id of the first order in the request.
contingency_type String Order list type.
Accepted values:
oneCancelOther (OCO) — all orders in the set should be canceled if one of them was executed;
oneTriggerOther (OTO) — execution of the first (primary) order on the list activates other (secondary) orders as independent of each other;
oneTriggerOneCancelOther (OTOCO) — the execution of the first (primary) order on the list activates the other (secondary) orders as an OCO order list.
orders []Order Orders in the list. There must be 2 or 3 orders for allOrNone/oneCancelOther/oneTriggerOther and 3 — for oneTriggerOneCancelOther. Placing any other number of orders will result in an error.

Order model consists of:

Name Type Description
client_order_id String Optional. Must be different from the identifiers of other orders in the list.
If omitted, it will be generated by the system upon order list creation. Uniqueness must be guaranteed until the last order with the same client_order_id becomes inactive (canceled, expired, or fully executed) and some time after that.
symbol String Symbol code.
Must be the same for all orders in an oneTriggerOneCancelOther order list (placing orders in different order books is not supported).
side String Trade side.
Accepted values: sell, buy
type String Optional. Order type.
Accepted values:
for oneCancelOther (and secondary orders in oneTriggerOneCancelOther) — limit, stopLimit, stopMarket, takeProfitLimit, takeProfitMarket;
for oneTriggerOneCancelOther — limit, market, stopLimit, stopMarket, takeProfitLimit, takeProfitMarket.
Default value: limit
time_in_force String Optional. Time in Force instruction.
Accepted values:
for oneCancelOther (and secondary orders in oneTriggerOneCancelOther) — GTC, IOC (except limit orders), FOK (except limit orders), Day, GTD;
for oneTriggerOneCancelOther — GTC, IOC, FOK, Day, GTD.
quantity String Order quantity.
price String Order price. Required if type is limit, stopLimit, or takeProfitLimit.
stop_price String The price level that triggers order activation. Required if type is stopLimit, stopMarket, takeProfitLimit, or takeProfitMarket.
expire_time DateTime Date of order expiration. Required if time_in_force is GTD.
strict_validate Boolean Price and quantity will be checked for incrementation within the symbol’s tick size and quantity step. See the symbol's tick_size and quantity_increment.
post_only Boolean Optional. If a post-only order causes a match with a pre-existing order as a taker, then the order will expire.
reduce_only Boolean Optional. Reduce-only order, being filled, guarantees not to put the position quantity to the point when the position flips.
display_quantity String Optional. The visible part of the hidden order quantity (the only valid value is '0').
margin_mode String Optional. Margin mode.
Accepted values: isolated, cross
Default: isolated
margin_auto Boolean Optional. Flag requesting AMM (auto margin management) for the margin account or position the order belongs to.
With AMM enabled, the margin account and the position are created by the order if they do not exist, and the required margin is reserved

[Page truncated to keep GeezerVison snappy.]

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.