BinanceAPI.NET
18.1.1.2
Please update to the most recent version to benefit from cache improvements
See the version list below for details.
dotnet add package BinanceAPI.NET --version 18.1.1.2
NuGet\Install-Package BinanceAPI.NET -Version 18.1.1.2
<PackageReference Include="BinanceAPI.NET" Version="18.1.1.2" />
paket add BinanceAPI.NET --version 18.1.1.2
#r "nuget: BinanceAPI.NET, 18.1.1.2"
// Install BinanceAPI.NET as a Cake Addin
#addin nuget:?package=BinanceAPI.NET&version=18.1.1.2
// Install BinanceAPI.NET as a Cake Tool
#tool nuget:?package=BinanceAPI.NET&version=18.1.1.2
Server Time Client
The Server Time Client
is used to produce high quality Timestamps
for requests
Unlike other libraries BinanceAPI.NET
deals completely in remote time, The local time doesn't matter and you don't need to sync your clock etc or use any external tools or the windows time service etc.
You do however have to wait for the Server Time Client
to start before you can make requests, It should start instantly but you can also wait to be sure.
if (!ServerTimeClient.IsReady())
{
await ServerTimeClient.WaitForStart(serverTimeStartWaitToken.Token).ConfigureAwait(false);
}
Authentication
AuthenticationProvider authenticationProvider = new AuthenticationProvider(api_key, api_secret);
RestClient restClient = new RestClient(authenticationProvider, serverTimeStartWaitToken.Token);
Change Keys/Provider
restClient.SetNewAuthentication(authenticationProvider);
Change Controller
When you aren't making requests you can change the endpoint controller
BaseClient.SetEndpointController = BinanceApiController.ONE;
Default Options Socket Client
Change default options for socket clients
SocketClient.SetDefaultOptions(new SocketClientHostOptions()
{
MaxReconnectTries = 50
});
Default Options Rest Client
Change the default options for Rest Clients
RestClient.SetDefaultOptions(new RestClientOptions()
{
SyncUpdateTime = 15,
ReceiveWindow = TimeSpan.FromMilliseconds(1000)
});
Create Rest Client
Create a rest client to make requests
RestClient restClient = new RestClient(serverTimeStartWaitToken.Token);
Create Socket Client
Create a socket client to connect/subscribe to sockets
SocketClient socketClient = new SocketClient();
Get the Server Time Ticks
Get the current Server Time Guess
according to the Server Time Client
ServerTimeClient.ServerTimeTicks
Raw Data
Some methods have a version that returns RestResultRaw
, which includes the raw data.
Raw data can converted back into an object very quickly using the included Translators
string exchangeInfoText = File.ReadAllText("pathToExchangeInfo");
BinanceExchangeInformation exchangeInfo = BinanceExchangeInformationTranslator.Translate(exchangeInfoText);
These methods all end with Raw
Order Endpoints
Spot
PlaceOrderLimit
Places a new limit order
restClient.Spot.Order.PlaceOrderLimitFull();
restClient.Spot.Order.PlaceOrderLimitResult();
restClient.Spot.Order.PlaceOrderLimitAck();
PlaceOrderMarket
Places a new market order
restClient.Spot.Order.PlaceOrderMarketFull();
restClient.Spot.Order.PlaceOrderMarketResult();
restClient.Spot.Order.PlaceOrderMarketAck();
PlaceTestOrder
Places a new test order.
Test orders are not actually being executed and just test the functionality.
restClient.Spot.Order.PlaceTestOrderFull();
GetOrder
Retrieves data for a specific order.
Either orderId
or origClientOrderId
should be provided.
restClient.Spot.Order.GetOrder();
GetOrders
Gets all orders for the provided symbol
restClient.Spot.Order.GetOrders();
GetOpenOrders
Gets a list of open orders
restClient.Spot.Order.GetOpenOrders();
GetUserTrades
Gets all user trades for provided symbol
restClient.Spot.Order.GetUserTrades();
CancelOrder
Cancels a pending order on a symbol
restClient.Spot.Order.CancelOrder();
CancelAllOpenOrders
Cancels all open orders on a symbol
restClient.Spot.Order.CancelAllOpenOrders()
Margin/Isolated
PlaceMarginOrderLimit
Margin account new limit order
restClient.Margin.Order.PlaceMarginOrderLimitFull();
restClient.Margin.Order.PlaceMarginOrderLimitResult();
restClient.Margin.Order.PlaceMarginOrderLimitAck();
PlaceMarginOrderMarket
Margin account new market order
restClient.Margin.Order.PlaceMarginOrderMarketFull();
restClient.Margin.Order.PlaceMarginOrderMarketResult();
restClient.Margin.Order.PlaceMarginOrderMarketAck();
GetMarginAccountOrder
Retrieves data for a specific margin account order.
Either orderId
or origClientOrderId
should be provided.
restClient.Margin.Order.GetMarginAccountOrder();
GetMarginAccountOrders
Gets all margin account orders for the provided symbol
restClient.Margin.Order.GetMarginAccountOrders();
GetMarginAccountOpenOrders
Gets a list of open margin account orders
restClient.Margin.Order.GetMarginAccountOpenOrders();
GetMarginAccountUserTrades
Gets all user margin account trades for provided symbol
restClient.Margin.Order.GetMarginAccountUserTrades();
CancelMarginOrder
Cancel an active order for margin account
restClient.Margin.Order.CancelMarginOrder();
CancelOpenMarginOrders
Cancel all active orders for a symbol
restClient.Margin.Order.CancelOpenMarginOrders();
Account Endpoints
General
GetAccountInfo
Gets the account information, including balances
restClient.General.GetAccountInfo();
GetAccountStatus
Gets the status of the account associated with the api key/secret
restClient.General.GetAccountStatus();
GetDailySpotAccountSnapshot
Get a daily account snapshot (balances)
restClient.General.GetDailySpotAccountSnapshot();
Margin
Transfer
Execute transfer between spot account and cross margin account.
restClient.Margin.System.Transfer();
GetMarginAccountInfo
Query margin account details
restClient.Margin.System.GetMarginAccountInfo();
GetMarginLevelInformation
Get personal margin level information for your account
restClient.Margin.System.GetMarginLevelInformation();
GetTransferHistory
Get history of transfers
restClient.Margin.System.GetTransferHistory();
GetForceLiquidationHistory
Get history of forced liquidations
restClient.Margin.System.GetForceLiquidationHistory();
GetMaxTransferAmount
Query max transfer-out amount
restClient.Margin.System.GetMaxTransferAmount();
Isolated
EnableIsolatedMarginAccount
Enable an isolated margin account
restClient.Margin.System.EnableIsolatedMarginAccount();
GetIsolatedMarginAccount
Isolated margin account info
restClient.Margin.System.GetIsolatedMarginAccount();
GetEnabledIsolatedMarginAccountLimit
Get max number of enabled isolated margin accounts
restClient.Margin.System.GetEnabledIsolatedMarginAccountLimit();
GetInterestIsolatedMarginData
Get interest isolated margin data
restClient.Margin.System.GetInterestIsolatedMarginData();
DisableIsolatedMarginAccount
Disable an isolated margin account
restClient.Margin.System.DisableIsolatedMarginAccount();
Lending Endpoints
Borrow
Borrow. Apply for a loan.
restClient.Lending.Borrow();
Repay
Repay loan for margin account.
restClient.Lending.Repay();
GetLoans
Query loan records
restClient.Lending.GetLoans();
GetRepays
Query repay records
restClient.Lending.GetRepays();
GetMaxBorrowAmount
Query max borrow amount
restClient.Lending.GetMaxBorrowAmount();
GetInterestHistory
Get history of interest
restClient.Lending.GetInterestHistory();
GetInterestRateHistory
Get history of interest rates
restClient.Lending.GetInterestRateHistory();
GetInterestMarginData
Get interest margin data
restClient.Lending.GetInterestMarginData();
Market Endpoints
Spot
GetTicker
Get data regarding the last 24 hours for the provided symbol
restClient.Spot.Market.GetTicker();
GetTickers
Get data regarding the last 24 hours for all symbols
restClient.Spot.Market.GetTickers();
GetAggTradeHistory
Gets compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price will have the quantity aggregated.
restClient.Spot.Market.GetAggregatedTradeHistory();
GetCurrentAvgPrice
Gets current average price for a symbol
restClient.Spot.Market.GetCurrentAvgPrice();
GetKlines
Get candlestick data for the provided symbol
restClient.Spot.Market.GetKlines();
GetTradeHistory
Gets the historical trades for a symbol
restClient.Spot.Market.GetTradeHistory();
GetRecentTradeHistory
Gets the recent trades for a symbol
restClient.Spot.Market.GetRecentTradeHistory();
GetBookPrice
Gets the best price/quantity on the order book for a symbol.
restClient.Spot.Market.GetBookPrice();
GetAllBookPrices
Gets the best price/quantity on the order book for all symbols.
restClient.Spot.Market.GetAllBookPrices();
GetPrice
Gets the price of a symbol
restClient.Spot.Market.GetPrice();
GetAllPrices
Get a list of the prices of all symbols
restClient.Spot.Market.GetAllPrices();
GetTradeFee
Gets the trade fee for a symbol
restClient.Spot.Market.GetTradeFee();
Margin
GetMarginAsset
Get a margin asset
restClient.Margin.Market.GetMarginAsset();
GetAllMarginAssets
Get all assets available for margin trading
restClient.Margin.Market.GetAllMarginAssets();
GetMarginPair
Get a margin pair
restClient.Margin.Market.GetMarginPair();
GetAllMarginPairs
Get all asset pairs available for margin trading
restClient.Margin.Market.GetAllMarginPairs();
GetMarginPriceIndex
Get margin price index
restClient.Margin.Market.GetMarginPriceIndex();
Isolated
GetIsolatedSymbol
Isolated margin symbol info for a specific symbol
restClient.Margin.Market.GetIsolatedMarginSymbol();
GetAllIsolatedSymbols
Isolated margin symbol info for all symbols
restClient.Margin.Market.GetAllIsolatedMarginSymbols();
Userstream Endpoints
Spot
StartUserStream
Starts a user stream by requesting a listen key.
This listen key can be used in subsequent requests to SubscribeToUserDataUpdates
The stream will close after 60 minutes unless a keep alive is send.
restClient.Spot.UserStream.StartUserStream();
KeepAliveUserStream
Sends a keep alive for the current user stream listen key to keep the stream from closing.
Stream auto closes after 60 minutes if no keep alive is send.
30 minute interval for keep alive is recommended.
restClient.Spot.UserStream.KeepAliveUserStream();
StopUserStream
Stops the current user stream
restClient.Spot.UserStream.StopUserStream();
Margin
StartUserStream
Starts a user stream for margin account by requesting a listen key.
This listen key can be used in subsequent requests to SubscribeToUserDataUpdates
The stream will close after 60 minutes unless a keep alive is send.
restClient.Margin.UserStream.StartUserStream();
KeepAliveUserStream
Sends a keep alive for the current user stream for margin account listen key to keep the stream from closing.
Stream auto closes after 60 minutes if no keep alive is send. 30 minute interval for keep alive is recommended.
restClient.Margin.UserStream.KeepAliveUserStream();
StopUserStream
Close the user stream for the cross margin account
restClient.Margin.UserStream.StopUserStream();
Isolated
StartIsolatedUserStream
Starts a user stream for margin account by requesting a listen key.
This listen key can be used in subsequent requests to SubscribeToUserDataUpdates
The stream will close after 60 minutes unless a keep alive is send.
restClient.Margin.IsolatedUserStream.StartIsolatedMarginUserStream();
KeepAliveIsolatedUserStream
Sends a keep alive for the current user stream for margin account listen key to keep the stream from closing.
Stream auto closes after 60 minutes if no keep alive is send. 30 minute interval for keep alive is recommended.
restClient.Margin.IsolatedUserStream.KeepAliveIsolatedMarginUserStream();
CloseIsolatedUserStream
Close the user stream for the isolated margin account
restClient.Margin.IsolatedUserStream.StopIsolatedMarginUserStream();
Common Endpoints
SetBnbBurnStatus
Sets the status of the BNB burn switch for spot trading and margin interest
restClient.General.SetBnbBurnStatus();
DustTransfer
Converts dust (small amounts of) assets to BNB
restClient.General.DustTransfer();
GetFundingWallet
Get funding wallet assets
restClient.General.GetFundingWallet();
Transfer
Transfers between accounts
restClient.General.Transfer();
GetUserCoins
Gets information of coins for a user
restClient.General.GetUserCoins();
GetAssetDividendRecords
Get asset dividend records
restClient.General.GetAssetDividendRecords();
GetBnbBurnStatus
Gets the status of the BNB burn switch for spot trading and margin interest
restClient.General.GetBnbBurnStatus();
GetServerTimeTicks
Get the server time ticks as reported by the binance server
long stt = await ServerTimeClient.GetServerTimeTicks().ConfigureAwait(false);
GetDustLog
Gets the history of dust conversions
restClient.General.GetDustLog();
GetExchangeInfo
Get's information about the exchange including rate limits and information on the provided symbol or symbols
restClient.Spot.System.GetExchangeInfo();
GetSystemStatus
Gets the status of the Binance platform
restClient.Spot.System.GetSystemStatus();
Ping
Pings the Binance API
restClient.Spot.System.Ping();
GetTradingStatus
Gets the trading status for the current account
restClient.General.GetTradingStatus();
GetTransfers
Get universal transfer history
restClient.General.GetTransfers();
Websocket Streams
User Data Streams
Subscribes to the account update stream. Prior to using this, one of the StartUserStream
methods should be called.
socketClient.UserDataStreams.Updates();
SymbolTickerUpdates
Subscribes to ticker updates stream for a specific symbol
socketClient.Subscribe.SymbolTickerUpdates()
AggregatedTradeUpdates
Subscribes to the aggregated trades update stream for the provided symbol
socketClient.Subscribe.AggregatedTradeUpdates()
TradeUpdates
Subscribes to the trades update stream for the provided symbol
socketClient.Subscribe.TradeUpdates()
KlineUpdates
Subscribes to the candlestick update stream for the provided symbols and intervals
socketClient.Subscribe.KlineUpdates()
SymbolMiniTickerUpdates
Subscribes to mini ticker updates stream for a specific symbol or symbols
socketClient.Subscribe.SymbolMiniTickerUpdates()
AllSymbolMiniTickerUpdates
Subscribes to mini ticker updates stream for all symbols
socketClient.Subscribe.AllSymbolMiniTickerUpdates()
BookTickerUpdates
Subscribes to the book ticker update stream for the provided symbol or symbols
socketClient.Subscribe.BookTickerUpdates()
AllBookTickerUpdates
Subscribes to the book ticker update stream for all symbols
socketClient.Subscribe.AllBookTickerUpdates()
SymbolTickerUpdates
Subscribes to ticker updates stream for a specific symbol or symbols
socketClient.Subscribe.SymbolTickerUpdates()
AllSymbolTickerUpdates
Subscribes to ticker updates stream for all symbols
socketClient.Subscribe.AllSymbolTickerUpdates()
Reconnect Stream
SocketClientHost example = socketClient.Subscribe.SymbolMiniTickerUpdates(...);
example.ReconnectSocket();
Destroy Stream
SocketClientHost example = socketClient.Subscribe.SymbolMiniTickerUpdates(...);
example.DestroySocket();
Socket Status
SocketClientHost example = socketClient.Subscribe.SymbolMiniTickerUpdates(...);
example.ConnectionStatusChanged += BinanceSocket_StatusChanged;
private static void BinanceSocket_StatusChanged(ConnectionStatus obj);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- AsyncBlocker.NET (>= 1.0.1.3)
- BinanceUriCache (>= 1.0.2.3)
- High_Resolution_Sleep (>= 1.1.2.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
26.1.0.33 | 323 | 4/26/2024 |
This update
-----
Add AUTO_BORROW_REPAY to Margin
Add autoRepayAtCancel to Margin
Recent
------
Update High Resolution Sleep to v1.1.2.4
Add UserDataStreams.UpdatesRaw
Move several Margin endpoints to Margin.System, See documentation
Library no longer depends on Newtonsoft.Json
You can now subscribe to the raw data for all SocketClientHosts
Fix GetMarginLevelInformation
Add GetUserTradesRaw
Add GetOrdersRaw
Add GetOpenOrdersRaw
Add GetOrderRaw
Add GetMarginAccountUserTradesRaw
Add GetMarginAccountOrdersRaw
Add GetMarginAccountOpenOrdersRaw
Add GetMarginAccountOrderRaw
Add BinanceOrderSpotTranslator
Add BinanceOrderMarginTranslator
Add BinanceTradeTranslator
Add AggregatedTradeUpdatesRaw
Add TradeUpdatesRaw
Add KlineUpdatesRaw
Add SymbolMiniTickerUpdatesRaw
Add BookTickerUpdatesRaw
Add SymbolTickerUpdatesRaw
Add AllSymbolMiniTickerUpdatesRaw
Add AllSymbolTickerUpdatesRaw
Add BinanceStreamTickTranslator
Add BinanceStreamBookPriceTranslator
Add BinanceStreamMiniTickTranslator
Add BinanceStreamKlineTranslator
Add BinanceStreamAggregatedTranslator
Add BinanceStreamTradeTranslator
Add BinanceLoanRecords which replaces the BinanceQueryRecord
Add BinanceLoanRecordsTranslator
Add BinanceLoanTranslator
Add MarginStatusEnumTranslator
Add BinanceRepayRecords which replaces the BinanceQueryRecord
Add BinanceRepayRecordsTranslator
Add BinanceRepayTranslator
Add BinanceInterestHistoryRecords which replaces the BinanceQueryRecord
Add BinanceInterestHistoryRecordsTranslator
Add BinanceInterestHistoryTranslator
Add BinanceInterestRateHistoryTranslator
Add BinanceInterestMarginDataTranslator
Add StringTranslator
Add BinanceLendingInterestHistoryTranslator
Add LendingTypeEnumTranslator
Add BinanceTransferRecords which replaces the BinanceQueryRecord
Add UniversalTransferEnumTranslator
Add BinanceTransferRecordsTranslator
Add BinanceTransferTranslator
Add BinanceOrderLimitsTranslator
Add BinanceDividendRecords which replaces the BinanceQueryRecord
Add BinanceDividendRecordsTranslator
Add BinanceDividendRecordTranslator
Add BinanceDustTransferResultEntryTranslator
Add BinanceDustTransferResultTranslator
Add BinanceDustLogDetailsTranslator
Add BinanceDustLogListTranslator
Add BinanceDustLogTranslator
Add BinanceBnbBurnStatusTranslator
Add GetAccountInfoRaw
Add BinanceAccountInfoTranslator
Add BinanceAccountStatusTranslator
Add BinanceFundingAssetTranslator
Add BinanceNetworkTranslator
Add BinanceTradingStatusTranslator
Add BinanceUserCoinTranslator
Add TradingStatusDataTranslator
Add DictionaryTranslator
Add GetDailyMarginAccountSnapshotRaw
Add GetDailySpotAccountSnapshotRaw
Update GetDailySpotAccountSnapshot
Update GetDailyMarginAccountSnapshot
Add BinanceIsolatedMarginSymbolTranslator
Add BinanceMarginAssetTranslator
Add BinanceMarginPairTranslator
Add BinanceMarginPriceIndexTranslator
Add BinanceInterestIsolatedMarginDataTranslator
Add BinanceIsolatedInterestDataTranslator
Add IsolatedMarginAccountLimitTranslator
Rename CreateIsolatedMarginAccountResult to IsolatedMarginAccountResult
Add BinanceIsolatedMarginAccountTranslator
Add BinanceIsolatedMarginAccountAssetTranslator
Add BinanceIsolatedMarginAccountSymbolTranslator
Add IsolatedMarginAccountResultTranslator
Add BinanceForcedLiquidationRecords which replaces the BinanceQueryRecord
Add BinanceMarginAccountTranslator
Add BinanceMarginAmountTranslator
Add BinanceMarginBalanceTranslator
Add BinanceForcedLiquidationTranslator
Add BinanceTransferHistoryRecords which replaces the BinanceQueryRecord
Add TransferOrigin Enum
Add TransferFrom to BinanceTransferHistory which uses TransferOrigin
Add TransferTo to BinanceTransferHistory which uses TransferOrigin
Add FromSymbol to BinanceTransferHistory
Add ToSymbol to BinanceTransferHistory
Add BinanceTransferHistoryTranslator
Add BinanceTransactionTranslator
Add BinanceMarginLevelTranslator
Add TransferOriginTranslator
Add RestResultRaw which also returns the original data
Add GetRecentTradeHistoryRaw
Add GetTradeHistoryRaw
Add GetAggregatedTradeHistoryRaw
Add GetKlinesRaw
Add GetAllExchangeInfoRaw
Add GetTickersRaw
Add GetAllPricesRaw
Add GetAllBookPricesRaw
Add GetTradeFeeRaw
Add PlaceOrderLimitFullRaw
Add PlaceOrderLimitResultRaw
Add PlaceOrderLimitAckRaw
Add PlaceOrderMarketFullRaw
Add PlaceOrderMarketResultRaw
Add PlaceOrderMarketAckRaw
Add PlaceMarginOrderLimitFullRaw
Add PlaceMarginOrderLimitResultRaw
Add PlaceMarginOrderLimitAckRaw
Add PlaceMarginOrderMarketFullRaw
Add PlaceMarginOrderMarketResultRaw
Add PlaceMarginOrderMarketAckRaw
You can use the included Translators to turn the raw data into objects very quickly