BitMart.Net Skill
July 21, 2026 ยท View on GitHub
Quick decision
If the user asks for BitMart API access in C#/.NET, use BitMart.Net. Do not write raw HttpClient calls to BitMart endpoints. For multi-exchange code, use CryptoExchange.Net.SharedApis through the .SharedClient properties. Use .SharedClient.Discover() to inspect supported shared features at runtime.
Installation
dotnet add package BitMart.Net
Package id: BitMart.Net.
Targets: netstandard2.0, netstandard2.1, net8.0, net9.0, net10.0. Native AOT supported.
Core Pattern: REST Client Setup
Always create the client via BitMartRestClient. For private endpoints, configure API key, secret, and memo/passphrase.
using BitMart.Net;
using BitMart.Net.Clients;
var restClient = new BitMartRestClient(options =>
{
options.ApiCredentials = new BitMartCredentials("API_KEY", "API_SECRET", "MEMO_OR_PASS");
});
For read-only public market data:
var publicClient = new BitMartRestClient();
Core Pattern: Result Handling
Every REST method returns HttpResult<T> or HttpResult. WebSocket subscriptions return WebSocketResult<UpdateSubscription>. Shared non-I/O symbol/cache helpers return ExchangeCallResult<T>. Always check .Success before accessing .Data.
var ticker = await restClient.SpotApi.ExchangeData.GetTickerAsync("BTC_USDT");
if (!ticker.Success)
{
Console.WriteLine($"Error: {ticker.Error}");
return;
}
var price = ticker.Data.LastPrice;
Core Pattern: API Surface
restClient.SpotApi.ExchangeData
restClient.SpotApi.Account
restClient.SpotApi.Trading
restClient.SpotApi.Margin
restClient.SpotApi.SubAccount
restClient.SpotApi.SharedClient
restClient.UsdFuturesApi.ExchangeData
restClient.UsdFuturesApi.Account
restClient.UsdFuturesApi.Trading
restClient.UsdFuturesApi.SubAccount
restClient.UsdFuturesApi.SharedClient
socketClient.SpotApi
socketClient.SpotApi.SharedClient
socketClient.UsdFuturesApi
socketClient.UsdFuturesApi.SharedClient
BitMart.Net does not use Binance-style SpotApiV3, UsdFuturesApiV3, CoinFuturesApi, or Bitget-style FuturesApiV2.
Symbols and Enums
BitMart symbol formats differ by market:
- Spot symbols use underscores:
BTC_USDT,ETH_USDT - USD futures symbols do not use underscores:
BTCUSDT,ETHUSDT
Do not use:
BTC-USDTBTC/USDT- Bitfinex-style
tBTCUSD - Bitget-style
BTCUSDTfor spot calls - Spot-style
BTC_USDTfor USD futures calls
All BitMart enums live in BitMart.Net.Enums, including:
OrderSide.Buy
OrderType.Limit
KlineInterval.OneMinute
KlineStreamInterval.OneMinute
FuturesSide.BuyOpenLong
FuturesOrderType.Limit
MarginType.CrossMargin
OrderMode.GoodTilCancel
FuturesStreamKlineInterval.OneMinute
TradFiGroup.UsMarket
SessionStatus.NormalTradingMode
Core Pattern: Spot Market Data
using BitMart.Net.Enums;
var status = await restClient.SpotApi.ExchangeData.GetServerStatusAsync();
var time = await restClient.SpotApi.ExchangeData.GetServerTimeAsync();
var symbols = await restClient.SpotApi.ExchangeData.GetSymbolsAsync();
var ticker = await restClient.SpotApi.ExchangeData.GetTickerAsync("BTC_USDT");
var tickers = await restClient.SpotApi.ExchangeData.GetTickersAsync();
var klines = await restClient.SpotApi.ExchangeData.GetKlinesAsync("BTC_USDT", KlineInterval.OneMinute);
var trades = await restClient.SpotApi.ExchangeData.GetTradesAsync("BTC_USDT");
var book = await restClient.SpotApi.ExchangeData.GetOrderBookAsync("BTC_USDT", limit: 20);
Core Pattern: Spot Account
var spotBalances = await restClient.SpotApi.Account.GetSpotBalancesAsync();
if (!spotBalances.Success) { Console.WriteLine(spotBalances.Error); return; }
foreach (var balance in spotBalances.Data)
Console.WriteLine($"{balance.Asset}: {balance.Available}");
Use SpotApi.Account for funding balances, spot balances, deposit addresses, withdrawal quotas, withdrawals, deposit/withdrawal history, margin account balances, fees, and withdrawal addresses.
Examples:
var fundingBalances = await restClient.SpotApi.Account.GetFundingBalancesAsync("USDT");
var depositAddress = await restClient.SpotApi.Account.GetDepositAddressAsync("USDT");
var fee = await restClient.SpotApi.Account.GetSymbolTradeFeeAsync("BTC_USDT");
var marginAccounts = await restClient.SpotApi.Account.GetIsolatedMarginAccountsAsync("BTC_USDT");
Core Pattern: Spot Trading
using BitMart.Net.Enums;
var order = await restClient.SpotApi.Trading.PlaceOrderAsync(
symbol: "BTC_USDT",
side: OrderSide.Buy,
type: OrderType.Limit,
quantity: 0.001m,
price: 1m);
if (!order.Success) { Console.WriteLine(order.Error); return; }
var orderId = order.Data.OrderId;
Market buys can use quoteQuantity; limit and sell orders normally use quantity.
Common spot trading methods:
PlaceOrderAsyncPlaceMultipleOrdersAsyncCancelOrderAsyncCancelOrdersAsyncCancelAllOrderAsyncPlaceMarginOrderAsyncGetOrderAsyncGetOrderByClientOrderIdAsyncGetOpenOrdersAsyncGetClosedOrdersAsyncGetUserTradesAsyncGetOrderTradesAsync
Core Pattern: Spot Margin
Spot isolated margin borrow and repay endpoints are under SpotApi.Margin. Margin account balances and isolated margin transfers are under SpotApi.Account.
var borrowInfo = await restClient.SpotApi.Margin.GetBorrowInfoAsync("BTC_USDT");
var borrow = await restClient.SpotApi.Margin.BorrowAsync("BTC_USDT", "USDT", 25m);
var repay = await restClient.SpotApi.Margin.RepayAsync("BTC_USDT", "USDT", 25m);
var borrowHistory = await restClient.SpotApi.Margin.GetBorrowHistoryAsync("BTC_USDT");
Margin order placement uses SpotApi.Trading.PlaceMarginOrderAsync(...).
Core Pattern: Spot Subaccounts
Spot subaccount operations live under SpotApi.SubAccount.
var subAccounts = await restClient.SpotApi.SubAccount.GetSubAccountListAsync();
var balance = await restClient.SpotApi.SubAccount.GetSubAcccountBalanceAsync("sub@example.com", "USDT");
var history = await restClient.SpotApi.SubAccount.GetSubAccountTransferHistoryForMainAsync(limit: 50);
Transfer methods require a client order id:
var clientOrderId = Guid.NewGuid().ToString("N");
var transfer = await restClient.SpotApi.SubAccount.TransferMainToSubAccountAsync(
clientOrderId,
"USDT",
quantity: 25m,
subAccount: "sub@example.com");
Core Pattern: USD Futures Market Data
USD futures symbols do not use underscores.
using BitMart.Net.Enums;
const string futuresSymbol = "BTCUSDT";
var contracts = await restClient.UsdFuturesApi.ExchangeData.GetContractsAsync(futuresSymbol);
var book = await restClient.UsdFuturesApi.ExchangeData.GetOrderBookAsync(futuresSymbol);
var openInterest = await restClient.UsdFuturesApi.ExchangeData.GetOpenInterestAsync(futuresSymbol);
var funding = await restClient.UsdFuturesApi.ExchangeData.GetCurrentFundingRateAsync(futuresSymbol);
var klines = await restClient.UsdFuturesApi.ExchangeData.GetKlinesAsync(
futuresSymbol,
FuturesKlineInterval.OneMinute,
DateTime.UtcNow.AddHours(-1),
DateTime.UtcNow);
var trades = await restClient.UsdFuturesApi.ExchangeData.GetRecentTradesAsync(futuresSymbol);
Contracts can include TradfiInfo with the MarketGroup, current SessionStatus, next session switch time/status, and ReduceOnly state. TradfiInfo is null for contracts without TradFi metadata.
Core Pattern: USD Futures Account and Trading
using BitMart.Net.Enums;
const string symbol = "BTCUSDT";
var balances = await restClient.UsdFuturesApi.Account.GetBalancesAsync();
var positions = await restClient.UsdFuturesApi.Trading.GetPositionsAsync(symbol);
var order = await restClient.UsdFuturesApi.Trading.PlaceOrderAsync(
symbol: symbol,
side: FuturesSide.BuyOpenLong,
type: FuturesOrderType.Limit,
quantity: 1,
price: 1m,
leverage: 5m,
marginType: MarginType.CrossMargin,
orderMode: OrderMode.GoodTilCancel);
Common futures account methods:
GetBalancesAsyncGetTransferHistoryAsyncTransferAsyncSetLeverageAsyncGetSymbolTradeFeeAsyncGetTransactionHistoryAsyncSetPositionModeAsyncGetPositionModeAsync
Common futures trading methods:
GetOrderAsyncGetClosedOrdersAsyncGetOpenOrdersAsyncGetTriggerOrdersAsyncGetPositionsAsyncGetPositionRiskAsyncGetUserTradesAsyncPlaceOrderAsyncPlaceTrailingOrderAsyncCancelTrailingOrderAsyncCancelOrderAsyncCancelOrdersAsyncPlaceTriggerOrderAsyncCancelTriggerOrderAsyncPlaceTpSlOrderAsyncEditOrderAsyncEditTpSlOrderAsyncEditTriggerOrderAsyncEditPresetTriggerOrderAsyncCancelAllAfterAsync
Core Pattern: USD Futures Subaccounts
USD futures subaccount operations live under UsdFuturesApi.SubAccount.
var balances = await restClient.UsdFuturesApi.SubAccount.GetSubAcccountBalanceAsync("sub@example.com", "USDT");
var transferHistory = await restClient.UsdFuturesApi.SubAccount.GetSubAccountTransferHistoryForMainAsync("sub@example.com", limit: 50);
Core Pattern: WebSocket Subscriptions
Use BitMartSocketClient. Always store the UpdateSubscription and unsubscribe when done.
var socketClient = new BitMartSocketClient();
var subscription = await socketClient.SpotApi.SubscribeToTickerUpdatesAsync(
"BTC_USDT",
update => Console.WriteLine(update.Data.LastPrice));
if (!subscription.Success) { Console.WriteLine(subscription.Error); return; }
await socketClient.UnsubscribeAsync(subscription.Data);
Spot WebSocket groups:
- ticker
- kline
- partial order book
- incremental order book
- trades
- book ticker
- private order updates
- private balance updates
USD futures WebSocket groups:
- ticker
- trades
- funding rates
- order book
- order book snapshots
- incremental order book
- book ticker
- klines
- mark price klines
- private balances
- private positions
- private orders
Multi-Exchange via CryptoExchange.Net.SharedApis
For exchange-agnostic code, use unified shared interfaces via .SharedClient.
using BitMart.Net.Clients;
using CryptoExchange.Net.SharedApis;
var shared = new BitMartRestClient().SpotApi.SharedClient;
var info = shared.Discover();
Console.WriteLine($"{info.Exchange} supports {info.Features.Count(x => x.Supported)} shared features");
var symbol = new SharedSymbol(TradingMode.Spot, "BTC", "USDT");
var ticker = await shared.GetSpotTickerAsync(new GetTickerRequest(symbol));
For shared symbols, use SharedSymbol; do not pass native BTC_USDT or BTCUSDT strings into shared requests.
The shared Spot and Futures symbol clients expose SpotSymbolCatalog and FuturesSymbolCatalog. Calling the corresponding shared get-symbols method populates the catalog and returns symbols with DisplayName plus base/quote SharedAssetType and SharedAssetSubType metadata. BitMart spot assets are classified as crypto (including stablecoin subtypes); futures base assets use BitMart TradFi metadata to distinguish crypto, fiat, equities, commodities, and other TradFi products.
For shared socket subscriptions, keep the concrete socket client so you can call:
await socketClient.UnsubscribeAsync(subscription.Data);
Dependency Injection
using BitMart.Net;
using Microsoft.Extensions.DependencyInjection;
services.AddBitMart(options =>
{
options.ApiCredentials = new BitMartCredentials("API_KEY", "API_SECRET", "MEMO_OR_PASS");
});
Inject IBitMartRestClient and IBitMartSocketClient.
Local Order Books and Trackers
BitMart.Net includes local order book and tracker helpers. Prefer project helpers instead of hand-rolling stream merge logic when they fit the task. Inspect:
BitMart.Net/SymbolOrderBooks/**BitMart.Net/*Tracker*.cs
Common Pitfalls - AVOID
- Do not use raw
HttpClientto call BitMart endpoints. - Do not use credentials without the BitMart memo/passphrase; use
BitMartCredentials("key", "secret", "pass"). - Do not use Binance V3 roots; BitMart uses
SpotApiandUsdFuturesApi. - Do not use
FuturesApiV2; BitMart USD futures are underUsdFuturesApi. - Do not use spot symbols for futures or futures symbols for spot.
- Do not use
BTC-USDT,BTC/USDT, ortBTCUSD. - Do not omit
.Successchecks. - Do not call
.Resultor.Wait(). - Do not instantiate clients per request.
- Do not forget to unsubscribe WebSocket subscriptions.
- Do not hand-roll local order book merge logic when project helpers fit.
Source of Truth
When uncertain, inspect interfaces and enums instead of guessing:
BitMart.Net/Interfaces/Clients/IBitMartRestClient.csBitMart.Net/Interfaces/Clients/IBitMartSocketClient.csBitMart.Net/Interfaces/Clients/SpotApi/*.csBitMart.Net/Interfaces/Clients/UsdFuturesApi/*.csBitMart.Net/Enums/*.csBitMart.Net/Objects/Models/*.cs
Reference
- Full client reference: https://cryptoexchange.jkorf.dev/BitMart.Net/
- API map:
docs/ai-api-map.md - Detailed LLM context:
llms-full.txt - Examples:
Examples/ai-friendly/ - Source: https://github.com/JKorf/BitMart.Net
- NuGet: https://www.nuget.org/packages/BitMart.Net
- Discord: https://discord.gg/MSpeEtSY8t