Input parameters and response values are mapped to discriptive enum values where possible
Automatic websocket (re)connection management
Client side rate limiting
Client side order book implementation
Extensive logging
Support for different environments (binance.com, binance.us, testnet)
Easy integration with other exchange client based on the CryptoExchange.Net base library
Supported Frameworks
The library is targeting both .NET Standard 2.0 and .NET Standard 2.1 for optimal compatibility
.NET implementation
Version Support
.NET Core
2.0 and higher
.NET Framework
4.6.1 and higher
Mono
5.4 and higher
Xamarin.iOS
10.14 and higher
Xamarin.Android
8.0 and higher
UWP
10.0.16299 and higher
Unity
2018.1 and higher
Install the library
NuGet
dotnet add package Binance.Net
GitHub packages
Binance.Net is available on GitHub packages. You'll need to add https://nuget.pkg.github.com/JKorf/index.json as a NuGet package source.
Download release
The NuGet package files are added along side the source with the latest GitHub release which can found here.
How to use
REST Endpoints
// Get the ETH/USDT ticker via rest request
var restClient = new BinanceRestClient();
var tickerResult = await restClient.SpotApi.ExchangeData.GetTickerAsync("ETHUSDT");
var lastPrice = tickerResult.Data.LastPrice;
Websocket streams
// Subscribe to ETH/USDT ticker updates via the websocket API
var socketClient = new BinanceSocketClient();
var tickerSubscriptionResult = socketClient.SpotApi.ExchangeData.SubscribeToTickerUpdatesAsync("ETHUSDT", (update) =>
{
var lastPrice = update.Data.LastPrice;
});
Get started and request the last price of a symbol in 40 seconds
Binance.Net is based on the CryptoExchange.Net base library. Other exchange API implementations based on the CryptoExchange.Net base library are available and follow the same logic.
Added dedicated connection configuration; a websocket connection can now be established before making the first request by calling binanceSocketClient.SpotApi.PrepareConnectionsAsync();
Added CancellationToken optional parameter to websocket requests
Updated response models from classes to records
Version 9.10.0 - 11 Jun 2024
Added new SpotApi.Trading.PlaceOtoOrderListAsync and SpotApi.Trading.PlaceOtocoOrderListAsync endpoints
Fixed GetProductsAsync endpoints by allowing automatic decompression
Added Brokerage client, various fixes, added some missing parameters
Version 5.1.0-alpha9 - 01 May 2020
Fixed GetExchangeInfo call, merged master
Version 5.1.0-alpha8 - 19 Mar 2020
Futures update
Version 5.1.0-alpha7 - 16 Mar 2020
fixed reference
Version 5.1.0-alpha6 - 16 Mar 2020
Fixed ticker stream
Version 5.1.0-alpha5 - 16 Mar 2020
Futures update
Version 5.1.0-alpha4 - 06 Mar 2020
Actual stream fixes
Version 5.1.0-alpha3 - 06 Mar 2020
Futures stream fixes
Version 5.1.0-alpha2 - 03 Mar 2020
Updated CryptoExchange version
Version 5.1.0-alpha - 03 Mar 2020
First version Futures Api implementation
Version 5.0.10 - 01 May 2020
Fixed filter parsing in GetExchangeInfo
Version 5.0.9 - 03 Mar 2020
Fixed serialization issue on DustTransfer assets parameter
Version 5.0.8 - 03 Mar 2020
Added SideEffectType and MarginBuyBorrow properties
Added trade rules check for margin orders
Version 5.0.7 - 05 Feb 2020
Fixed incorrect Invalid symbol error
Version 5.0.6 - 27 Jan 2020
Updated CryptoExchange.Net
Version 5.0.5 - 23 Jan 2020
Added option for custom url
Version 5.0.4 - 10 Dec 2019
Fix for BinanceSymbolOrderBook
Version 5.0.3 - 13 Nov 2019
Updated for new API version
Added QuoteOrderQuantity parameter/property
Add stream balance update
Added precisions to ExchangeInfo symbols
Version 5.0.1 - 23 Oct 2019
Fixed validation for 9 length symbols
Version 5.0.1 - 23 Oct 2019
Fixed validation for 5 length symbols
Version 5.0.0 - 23 Oct 2019
See CryptoExchange.Net 3.0 release notes
Added input validation
Added CancellationToken support to all requests
Now using IEnumerable<> for collections
Renamed various methods to be more in line with other exchanges
Renamed SubscribeToXXXStream to SubscribeToXXXUpdates
Version 4.3.3 - 06 Oct 2019
Added serialization method for BinanceSymbolFilter
Version 4.3.2 - 25 Sep 2019
Added missing AddressTag and TransactionFee properties in withdrawal object
Version 4.3.1 - 03 Sep 2019
Added book ticker stream to socket client
Version 4.3.0 - 02 Sep 2019
Added new Margin endpoints
Renamed Query- methods to Get- methods for consistency
Version 4.2.3 - 29 Aug 2019
Added DustTransfer and GetDividendRecords endpoints
Added updateInterval parameter to depth streams
Version 4.2.2 - 20 Aug 2019
Added missing margin endpoints
IndicatorType to enum
Version 4.2.1 - 19 Aug 2019
Added current average price endpoint
Version 4.2.0 - 15 Aug 2019
Implemented OCO orders
Adjustments for API update
Version 4.1.3 - 12 Aug 2019
Fix margin order cancel
Version 4.1.2 - 07 Aug 2019
Updated CryptoExchange.Net
Version 4.1.1 - 05 Aug 2019
Added xml file for code docs
Version 4.1.0 - 30 Jul 2019
Added margin API
Version 4.0.17 - 09 jun 2019
Added TimestampOffset options
Update BinanceSymbolOrderBook
Version 4.0.16 - 20 may 2019
Fixed AutoComply trade rules behavior
Version 4.0.15 - 16 may 2019
Fixed order book limit implementation
Version 4.0.14 - 14 may 2019
Added an order book implementation for easily keeping an updated order book
Added additional constructor to ApiCredentials to be able to read from file
Version 4.0.13 - 01 may 2019
Updated to latest CryptoExchange.Net
Adds response header to REST call result
Added rate limiter per API key
Unified socket client workings
Version 4.0.12 - 09 apr 2019
Fixed type in FifteenMinutes kline interval enum
Added update time to BinanceStreamAccountInfo
Added IsSpotTradingAllowed and IsMarginTradingAllowed fields to BinanceSymbol
Added IDisposable to client interfaces
Version 4.0.11 - 02 apr 2019
Added Symbol field in BinanceTrade
Added deposit status Completed to deposits filter
Fixed Exception handler null reference if not set
Version 4.0.10 - 18 mar 2019
Added AutoReconnect option
Fix for error parsing without code/message
Added QuoteQuantity to MyTrades result
Version 4.0.9 - 07 mar 2019
Added start/end time parameters to GetAllOrders
Updated CryptoExchange.Net
Version 4.0.8 - 27 feb 2019
Added sub account support
Added trading status call
Changed CallResult to WebCallResult for REST requests to expose the response status
Version 4.0.7 - 01 feb 2019
Added exception event to subscriptions
General fixes
Version 4.0.6 - 10 jan 2019
Fix for timestamp calculation
Version 4.0.5 - 09 jan 2019
Adjusted AutoTimestamp calculation
Version 4.0.4 - 28 dec 2018
Another fix for reconnecting
Version 4.0.3 - 17 dec 2018
Fixed reconnecting sometimes throwing error
Version 4.0.2 - 10 dec 2018
TradeRuleBehavior.AutoComply rounding fix
Version 4.0.1 - 06 dec 2018
Fix for freezes if called from UI thread
Fixed AutoComply trade rules behavior
Fixed IDisposable interface
Version 4.0.0 - 05 dec 2018
Updated to CryptoExchange.Net version 2
Libraries now use the same standard functionalities
Objects returned by socket subscriptions standardized across libraries
Added start/endtime parameters to GetMyTrades
Version 3.3.0 - 15 nov 2018
Updated to support latest Binance API update, including:
Added RawRequest rate limit
Canceling an order now returns full order report
Added multiple symbol filters
Added LastQuoteTransactedQuantity to socket order update
Version 3.2.12 - 15 nov 2018
Added event time to BinanceStreamTick
Version 3.2.11 - 01 nov 2018
Exception handling in error response parsing
Version 3.2.10 - 24 oct 2018
AutoTimestamp now enabled by default
BaseAssetPrecision and QuoteAssetPrecision type from string to int
Version 3.2.9 - 18 oct 2018
Added default receiveWindow parameter to client options
Updated time calculation between server/client, should help people with unstable ping who got intermittent errors saying the local time was ahead of server time
Version 3.2.8 - 04 oct 2018
Fixed subscriptions trying to reconnect if initial subscribe fails
Added accessors for symbol filters
Fix subscription reconnections
Version 3.2.7 - 21 sep 2018
Updated CryptoExchange.Net
Version 3.2.6 - 17 sep 2018
Combined PartialBookDepthStream data object with DepthStream data object
Fix reconnection bug
Version 3.2.5 - 10 sep 2018
Added check for failed auto timestamp syncing
Added auto recalculation interval for auto timestamp
Version 3.2.4 - 07 sep 2018
Fixed proxy setting on socket client
Version 3.2.3 - 21 aug 2018
Fix for previous fix..
Version 3.2.2 - 21 aug 2018
Fix for default api credentials getting disposed
Version 3.2.1 - 20 aug 2018
Update CryptoExchange.Net for bugfix
Version 3.2.0 - 16 aug 2018
Added socket client interface
Moved interface to interface namespace
Fixed some minor Resharper findings
Version 3.1.18 - 13 aug 2018
Fix for userstream not connecting
Version 3.1.17 - 13 aug 2018
Updated CryptoExchange.Net to fix bug
Version 3.1.16 - 13 aug 2018
Updated CryptoExchange.Net
Fixed error response parsing
Version 3.1.15 - 24 jul 2018
Fixed missing Symbol filter type
Version 3.1.14 - 20 jul 2018
Added error parsing to code/message
Version 3.1.13 - 19 jul 2018
Update to latest api update adding various properties/filters
Version 3.1.12 - 17 jul 2018
Added GetAccountStatus endpoint
Added GetSystemStatus endpoint
Added GetDustLog endpoint
Version 3.1.11 - 16 jul 2018
Fix for UI thread freezing when unsubscribing a stream
Version 3.1.10 - 03 jul 2018
Small fix for socket event binding
Version 3.1.9 - 25 jun 2018
Fix for Unsubscribe freezing if called from UI thread
Version 3.1.8 - 08 jun 2018
Fix for DateTime parsing
Version 3.1.7 - 08 jun 2018
Added missing TradeId field in PlaceOrder response
Version 3.1.6 - 04 jun 2018
Fix for OrderUpdate mapping
Fix for BinanceSymbol mapping
Version 3.1.5 - 07 may 2018
Added resetAutoTimestamp parameter to server time
Version 3.1.4 - 03 may 2018
Additional debug logging
Version 3.1.3 - 30 apr 2018
Refactored combined streams to be easier to use and reduce duplicate code
Fixed threadsafety issue in authenticator
Version 3.1.2 - 19 apr 2018
Added combined streams
Version 3.1.1 - 16 apr 2018
Added receiveWindow parameter to PlaceOrder
Version 3.1.0 - 27 mar 2018
Added GetWithdrawalFee call
Refactored Klines some to have the stream and the rest data be more similair
Added code docs where missing
Version 3.0.11 - 23 mar 2018
Updated closed/reconnect handling for sockets
Updated base
Version 3.0.10 - 21 mar 2018
Now possible to add multiple log writers
Added automatic reconnecting after loss of internet
Fixed error when subsribing to a stream while passing Null as handler
Version 3.0.9 - 13 mar 2018
Added trade stream next to aggregated trade stream
Fix for BuyerIsMaker field always being true
Version 3.0.8 - 12 mar 2018
Fix for inconsistent int/long types
Fix for freezing when making calls from UI thread
Added auto reconnect functionality
Version 3.0.7 - 08 mar 2018
Updated base
Version 3.0.6 - 08 mar 2018
Fix for socket connecting in non dotnet core clients
Version 3.0.5 - 07 mar 2018
Fix for deserialization error handling
Socket opening async, subscribe methods async
Version 3.0.4 - 05 mar 2018
Added SetApiCredentials methods
Version 3.0.2/3.0.3 - 05 mar 2018
SetDefaultOptions made static
Version 3.0.1 - 05 mar 2018
Additional logging
Updated base verions
Version 3.0.0 - 01 mar 2018
Updated to use a base package, which introduces some changes in syntax, but keeps functionality unchanged
Version 2.3.4 - 12 feb 2018
Fix for AutoComply trading rules sending too much trailing zero's