Every private endpoint on BitMart — placing orders, reading balances, streaming account updates — requires a signed request. The SDK handles signing automatically once you supply your three credentials at client construction time. This page explains what each credential does, where to obtain them, and how to use them safely.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tiagosiebler/bitmart-api/llms.txt
Use this file to discover all available pages before exploring further.
How BitMart Authentication Works
BitMart uses HMAC-SHA256 to authenticate REST and WebSocket requests. For each signed request, the SDK builds a message in the form:apiSecret and attaches the result as the X-BM-SIGN header, alongside X-BM-KEY (your API key) and X-BM-TIMESTAMP.
The signature is computed using the Web Crypto API, which means the SDK works in both Node.js and browser environments without any additional dependencies. If you need higher throughput, you can substitute Node.js’s native createHmac via the customSignMessageFn option (see Custom Signing below).
The Three Required Credentials
| Field | Client option | Description |
|---|---|---|
| API Key | apiKey | A unique identifier for your API integration, generated on the BitMart dashboard. |
| API Secret | apiSecret | The secret used to produce the HMAC-SHA256 signature. Never share or expose this value. |
| API Memo | apiMemo | A human-readable label you choose when creating the API key. It acts as an additional factor in the signature and must match exactly what you set on the dashboard. |
The Memo is not a password — it is simply the label you typed when you created the API key on BitMart. It must be passed to the SDK exactly as you entered it.
Obtaining API Credentials
- Log in to https://www.bitmart.com/api-settings.
- Click Create API and enter a Memo (any descriptive label, e.g.
my-trading-bot). - Set the required IP allowlist and permissions (read-only, trading, withdrawal, etc.).
- Copy the API Key and API Secret — the secret is only shown once.
- Store all three values (
apiKey,apiSecret,apiMemo) securely before closing the page.
Initialising the REST Client
Pass your credentials toRestClient at construction time. The SDK validates at construction that all three values are present — passing only one or two will throw immediately.
Initialising the Futures Client
FuturesClientV2 accepts the same credentials and additionally supports a demoTrading flag to route requests to BitMart’s simulated futures environment.
The demo environment uses the same API keys as production. Only the base URL changes:
https://demo-api-cloud-v2.bitmart.com instead of https://api-cloud-v2.bitmart.com.Initialising the WebSocket Client
WebsocketClient accepts the same credentials. Private streams (account orders, positions, balances) require credentials; public streams (tickers, depth, klines) do not.
Public vs Private Endpoints
Not every endpoint requires authentication. Public endpoints return market data that BitMart makes freely available.| Type | Requires credentials | Examples |
|---|---|---|
| Public | No | getSpotTickersV3, getSpotHistoryKlineV3, getFuturesContractDetails |
| Private | Yes | getAccountBalancesV1, submitSpotOrderV2, getFuturesAccountAssets |
RestClient without credentials and it will work perfectly for public endpoints:
The recvWindow Parameter
The recvWindow value (in milliseconds) defines how long a signed request stays valid after it is generated. Requests that arrive at BitMart’s servers outside this window are rejected to prevent replay attacks.
- Default:
5000ms (5 seconds) - Global override: set
recvWindowin the client options to change the default for all calls - Per-call override: pass
recvWindowinside a method’s parameter object to override for that call only
Custom Signing
By default the SDK uses the Web Crypto API to compute HMAC-SHA256 signatures. In high-frequency scenarios you can inject Node.js’s nativecreateHmac via customSignMessageFn for lower latency:
Custom signing with
createHmac is Node.js-only. Do not use it in browser or edge-runtime builds where the crypto built-in is unavailable.Security Best Practices
Never hard-code API credentials in your source code. If a key is accidentally committed to version control it should be revoked immediately on the BitMart dashboard.
.env file with a package such as dotenv — but make sure .env is listed in your .gitignore: