Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tiagosiebler/binance/llms.txt
Use this file to discover all available pages before exploring further.
MainClient is the primary REST client for Binance’s core product suite. It targets the api*.binance.com family of subdomains and provides typed methods for Spot trading, Cross and Isolated Margin, Wallet operations, Convert, Simple Earn, Auto-Invest, Dual Investment, Staking, Mining, Crypto Loans, VIP Loans, NFTs, C2C, sub-account management, and more. If you are working with Spot or Margin markets — or any non-futures product — MainClient is the class you need.
Installation
Constructor Options
TheMainClient constructor accepts an optional RestClientOptions object followed by an optional Axios request-config for low-level HTTP customisation.
Your Binance API key. Required for all authenticated (private) endpoints.
Your Binance API secret. Required for HMAC-signed requests. Pass an RSA or Ed25519 private key here — the SDK detects the key type automatically.
When
true, the SDK parses numeric strings in responses into JavaScript numbers for well-known fields.Routes requests to
https://testnet.binance.vision. Useful for development and automated testing.Routes requests to Binance’s Demo Trading environment. This uses real market data with simulated order execution — ideal for strategy testing.
Method Categories
Market Data
Public endpoints — no API key required.| Method | Endpoint | Description |
|---|---|---|
testConnectivity() | GET api/v3/ping | Test connectivity to the REST API |
getExchangeInfo(params?) | GET api/v3/exchangeInfo | Exchange trading rules and symbol info |
getOrderBook(params) | GET api/v3/depth | Order book depth for a symbol |
getRecentTrades(params) | GET api/v3/trades | Recent trades list |
getAggregateTrades(params) | GET api/v3/aggTrades | Compressed aggregate trade list |
getKlines(params) | GET api/v3/klines | Kline/candlestick data |
getUIKlines(params) | GET api/v3/uiKlines | UI-optimised kline data |
getAvgPrice(params) | GET api/v3/avgPrice | Current average price |
get24hrChangeStatistics(params?) | GET api/v3/ticker/24hr | 24-hour rolling window statistics |
getSymbolPriceTicker(params?) | GET api/v3/ticker/price | Latest price for a symbol or all symbols |
getSymbolOrderBookTicker(params?) | GET api/v3/ticker/bookTicker | Best bid/ask price and quantity |
getRollingWindowTicker(params) | GET api/v3/ticker | Rolling window price change statistics |
getTradingDayTicker(params) | GET api/v3/ticker/tradingDay | Trading day price change statistics |
Order Management
Authenticated endpoints — requireapi_key and api_secret.
| Method | Endpoint | Description |
|---|---|---|
submitNewOrder(params) | POST api/v3/order | Place a new Spot order |
testNewOrder(params) | POST api/v3/order/test | Test order placement without execution |
getOrder(params) | GET api/v3/order | Query status of an order |
cancelOrder(params) | DELETE api/v3/order | Cancel an active order |
cancelAllSymbolOrders(params) | DELETE api/v3/openOrders | Cancel all open orders for a symbol |
replaceOrder(params) | POST api/v3/order/cancelReplace | Cancel and replace an order atomically |
getOpenOrders(params?) | GET api/v3/openOrders | Get all open orders |
getAllOrders(params) | GET api/v3/allOrders | Full order history for a symbol |
Order Lists (OCO / OTO / OTOCO)
| Method | Endpoint | Description |
|---|---|---|
submitNewOCO(params) | POST api/v3/order/oco | Place an OCO (One-Cancels-Other) order |
submitNewOrderList(params) | POST api/v3/orderList/oco | Place a new OCO order list |
submitNewOrderListOTO(params) | POST api/v3/orderList/oto | Place an OTO (One-Triggers-Other) order list |
submitNewOrderListOTOCO(params) | POST api/v3/orderList/otoco | Place an OTOCO order list |
submitNewOrderListOPO(params) | POST api/v3/orderList/opo | Place an OPO order list |
submitNewOrderListOPOCO(params) | POST api/v3/orderList/opoco | Place an OPOCO order list |
cancelOCO(params) | DELETE api/v3/orderList | Cancel an order list |
getOCO(params) | GET api/v3/orderList | Query a specific order list |
getAllOCO(params?) | GET api/v3/allOrderList | All order lists for the account |
getAllOpenOCO() | GET api/v3/openOrderList | All open order lists |
Account
| Method | Endpoint | Description |
|---|---|---|
getAccountInformation() | GET api/v3/account | Account balances and permissions |
getAccountTradeList(params) | GET api/v3/myTrades | Trade history for a symbol |
getCommissionRates(params) | GET api/v3/account/commission | Commission rates for a symbol |
getBalances() | GET sapi/v1/capital/config/getall | All coin balances with wallet info |
Margin Trading
| Method | Endpoint | Description |
|---|---|---|
getCrossMarginCollateralRatio() | GET sapi/v1/margin/crossMarginCollateralRatio | Cross-margin collateral ratios |
queryCrossMarginAccountDetails() | GET sapi/v1/margin/account | Cross-margin account details |
submitMarginAccountBorrowRepay(params) | POST sapi/v1/margin/borrow-repay | Borrow or repay margin assets |
getMarginAccountBorrowRepayRecords(params) | GET sapi/v1/margin/borrow-repay | Borrow/repay history |
marginAccountNewOrder(params) | POST sapi/v1/margin/order | Place a margin order |
marginAccountCancelOrder(params) | DELETE sapi/v1/margin/order | Cancel a margin order |
getIsolatedMarginAccountInfo(params?) | GET sapi/v1/margin/isolated/account | Isolated margin account details |
Code Examples
Product Coverage
MainClient covers an exceptionally wide range of Binance product groups. The table below summarises the main API families available.
Spot Trading
Order placement, cancellation, and history. Supports MARKET, LIMIT, STOP_LOSS, TAKE_PROFIT, and advanced order list types (OCO, OTO, OTOCO, OPO, OPOCO).
Margin Trading
Cross and isolated margin accounts, borrow/repay, margin orders, forced liquidation records, and interest history.
Wallet & Transfers
Deposit/withdrawal addresses and history, dust conversion, universal transfers, sub-account management, and fiat operations.
Convert & Earn
Convert API for instant swaps, Simple Earn flexible/locked products, Auto-Invest plans, Dual Investment, and Staking.
Crypto Loans
Borrow, repay, LTV adjustments, and liquidation history for both standard and flexible crypto loans. VIP Loan endpoints included.
Mining & NFTs
Mining account stats, hashrate resale, mining earnings, plus NFT asset/deposit/withdrawal history.
For USD-M Futures, use
USDMClient. For COIN-M Futures, use CoinMClient. For Portfolio Margin, use PortfolioClient.Full Endpoint Map
The complete list of allMainClient methods mapped to their exact API endpoints is maintained in the repository:
REST Endpoint Function List →