TheDocumentation 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.
bitmart-api SDK exposes two sets of configuration interfaces: RestClientOptions for the REST clients (RestClient and FuturesClientV2) and WSClientConfigurableOptions for the WebsocketClient. Both interfaces share a common subset of authentication fields, and each adds options specific to its transport layer. You pass these options as a plain object to the client constructor — every field is optional, so you only need to include what you want to override.
REST Client Options
These options apply to bothRestClient (spot & margin) and FuturesClientV2 (USD-M futures). Pass them as the first argument to the constructor.
Your BitMart API key. Required for all authenticated (private) endpoints. Create API keys in your BitMart account dashboard.
Your BitMart API secret. Used together with
apiKey to sign requests via HMAC-SHA256.The memo (label) you chose when creating your API key. This value is included in the request signature and must match what is stored on BitMart’s servers.
The default receive window in milliseconds for signed API calls. Controls how long a signed request remains valid after it is issued. If a method call also supplies
recvWindow, the per-call value takes precedence over this global default. Equivalent to BitMart’s X-BM-TIMESTAMP tolerance window.When
true, the SDK will throw an error if any parameter passed to a method is undefined. Useful during development to catch typos and missing fields early. Defaults to false (undefined params are silently dropped).Optionally override the API base URL for every request, e.g.
'https://api.bitmart.com'. Useful when routing traffic through a proxy or a corporate gateway. Takes precedence over both the demoTrading flag and the automatic client-type URL selection.When
true, the client routes all requests to BitMart’s simulated trading environment. Only effective for FuturesClientV2 — the demo URL used is https://demo-api-cloud-v2.bitmart.com. Spot (RestClient) and V1 futures continue using production endpoints regardless of this flag.When
true (the default), the SDK post-processes failed requests and re-throws a structured error object. Set to false to receive raw Axios errors if you prefer to handle HTTP-level errors yourself.Inject a custom HMAC signing function. By default, the SDK uses the Web Crypto API for browser compatibility. In Node.js you can supply
crypto.createHmac for a measurable throughput improvement on high-frequency workloads. See Custom Signing for a complete example.Enable HTTP keep-alive on the underlying Axios HTTP agent. When
true, TCP connections are reused across requests rather than torn down and re-established each time, reducing latency for bots that send many consecutive requests.When HTTP keep-alive is enabled, this sets the interval (in milliseconds) at which TCP keep-alive packets are sent over idle sockets. Only relevant when
keepAlive is true. Defaults to 1000 ms (inherited from Node.js’s https agent default).WebSocket Client Options
These options apply to theWebsocketClient. Authentication fields are identical to the REST options. Additional options control heartbeat timing and reconnection behaviour.
Your BitMart API key. Required to subscribe to private WebSocket channels (account orders, positions, balances).
Your BitMart API secret. Used to sign the WebSocket authentication message.
The memo associated with your API key. Included in the WebSocket authentication payload.
The receive window (in milliseconds) included in the WebSocket authentication signature. For example,
5000 means the authentication message is valid for 5 seconds from its timestamp. Defaults to the SDK’s internal default if not set.How often (in milliseconds) the client checks whether each WebSocket connection is still alive by sending a ping. Decrease this value if you need faster detection of dropped connections.
How long (in milliseconds) the client waits for a pong response after sending a ping before treating the connection as dead and scheduling a reconnect.
Delay in milliseconds before the client attempts to respawn a dropped WebSocket connection. After a disconnect is detected, the client waits this long before opening a new connection and resubscribing to all previous topics.
Additional options forwarded to the underlying HTTP request layer used during WebSocket handshake. Accepts any key-value pairs supported by the transport.
Pass additional options directly to the underlying
WebSocket constructor. Accepts protocols (string array), agent, and any field from WebSocket.ClientOptions or Node.js ClientRequestArgs. Useful for routing WebSocket traffic through an HTTP/HTTPS proxy agent.Optionally override the WebSocket endpoint URL. Useful for proxies, internal test environments, or routing to a specific regional endpoint.
When
true, the WebSocket client connects to BitMart’s simulated futures trading environment at wss://openapi-wsdemo-v2.bitmart.com. Only applies to V2 Futures WebSocket streams — spot streams always use the production endpoint.Inject a custom HMAC signing function for WebSocket authentication messages, identical in signature to the REST option. See Custom Signing for details.