BinanceAPI.NET 26.0.3.1

dotnet add package BinanceAPI.NET --version 26.0.3.1
NuGet\Install-Package BinanceAPI.NET -Version 26.0.3.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BinanceAPI.NET" Version="26.0.3.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BinanceAPI.NET --version 26.0.3.1
#r "nuget: BinanceAPI.NET, 26.0.3.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BinanceAPI.NET as a Cake Addin
#addin nuget:?package=BinanceAPI.NET&version=26.0.3.1

// Install BinanceAPI.NET as a Cake Tool
#tool nuget:?package=BinanceAPI.NET&version=26.0.3.1

alternate text is missing from this package README image Nuget

EXAMPLE Authentication

AuthenticationProvider authenticationProvider = new AuthenticationProvider(api_key, api_secret);

RestClient restClient = new RestClient(authenticationProvider, serverTimeStartWaitToken.Token);

Change Keys/Provider

restClient.SetNewAuthentication(authenticationProvider);

EXAMPLE Change Controller

When you aren't making requests you can change the endpoint controller

BaseClient.SetEndpointController = BinanceApiController.ONE;

EXAMPLE Default Options Socket Client

Change default options for socket clients

SocketClient.SetDefaultOptions(new SocketClientHostOptions()
{
    MaxReconnectTries = 50
});

EXAMPLE Default Options Rest Client

Change the default options for Rest Clients

RestClient.SetDefaultOptions(new RestClientOptions()
{
    SyncUpdateTime = 15,
    ReceiveWindow = TimeSpan.FromMilliseconds(1000)
});

EXAMPLE Create Rest Client

Create a rest client to make requests

RestClient restClient = new RestClient(serverTimeStartWaitToken.Token);

EXAMPLE Create Socket Client

Create a socket client to connect/subscribe to sockets

SocketClient socketClient = new SocketClient();

EXAMPLE Get the Server Time Ticks

Get the current Server Time Guess according to the Server Time Client

ServerTimeClient.ServerTimeTicks

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);
}

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 Generators

string exchangeInfoText = File.ReadAllText("pathToExchangeInfo");

BinanceExchangeInformation exchangeInfo = BinanceExchangeInformationGenerator.Create(exchangeInfoText);

These methods all end with Raw


Cache Client

The library provides objects so that certain data about orders can be cached for fast access to order placement endpoints.

You are responsible for creating the cache and storing the Cachable objects.


CachableHttpRequestMessagePost

A HttpRequestMessage that uses HttpMethod.Post that can be used for a future request

These are intended for single use

CachableHttpRequestMessagePost cachableHttpRequest = CacheClient.CreatePostRequest(authHeader);

CachableHttpRequestMessagePost cachableHttpRequest = CacheClient.CreatePostRequestAddAuth(ref restClient);

CachableHttpRequestMessagePost cachableHttpRequest = CacheClient.CreatePostRequestAddAuth(ref authProvider);

It is possible to Clear() the CachableHttpRequestMessagePost after the request to make it reusable, this is not thread safe.

Auth Header is only cached once, its recommended to create multiple objects instead of using Clear()

If you re-use a request after using Clear() the Auth Header will be added the usual way.


CachableSpotRequest

Create a spot order request so it can be cached and reused

CachableSpotRequest cachableSpotRequest = CacheClientSpot.CreateOrderLimit();

CachableMarginRequest

Create a margin order request so it can be cached and reused

CachableMarginRequest cachableMarginRequest = CacheClientMargin.CreateMarginOrderLimit();

Order Endpoints

Spot Orders

CreateOrderLimit

Create a new cachable limit order that can be used in multiple future requests

CachableSpotRequest order = CacheClientSpot.CreateOrderLimit();

CreateOrderMarket

Create a new cachable market order that can be used in multiple future requests

CachableSpotRequest order = CacheClientSpot.CreateOrderMarket();

POST PlaceOrderSpotCached

Place a Spot Order from data that can be cached

CachableHttpRequestMessagePost request = CacheClient.CreatePostRequestAddAuth(ref restClient);

CachableSpotRequest order = CacheClientSpot.CreateOrderMarket(symbolName, orderSide, orderQuantity, recvWindow);

RestResult<BinancePlacedOrderSpot> result = restClient.Spot.Order.PlaceOrderSpot(ref order, ref request);

Place a Spot Order from data that can be cached and also return a copy of the raw response

RestResultRaw<BinancePlacedOrderSpot> result = restClient.Spot.Order.PlaceOrderSpotRaw(ref order, ref request);

POST PlaceTestOrder

Places a new test order.

Test orders are not actually being executed and just test the functionality.

CachableHttpRequestMessagePost httpRequestMessagePost = CacheClient.CreatePostRequestAddAuth(ref restClient);

CachableSpotRequest spotRequest = CacheClientSpot.CreateOrderMarket("BTCUSDT", OrderSide.Sell, 1, 1000);

RestResult<BinancePlacedOrderSpot> result = restClient.Spot.Order.PlaceTestOrder(ref spotRequest, ref httpRequestMessagePost);

GET GetOrder

Retrieves data for a specific order.

Either orderId or origClientOrderId should be provided.

restClient.Spot.Order.GetOrder();

GET GetOrders

Gets all orders for the provided symbol

restClient.Spot.Order.GetOrders();

GET GetOpenOrders

Gets a list of open orders

restClient.Spot.Order.GetOpenOrders();

GET GetUserTrades

Gets all user trades for provided symbol

restClient.Spot.Order.GetUserTrades();

DELETE CancelOrder

Cancels a pending order on a symbol

restClient.Spot.Order.CancelOrder();

DELETE CancelAllOpenOrders

Cancels all open orders on a symbol

restClient.Spot.Order.CancelAllOpenOrders()

Margin/Isolated Orders

CreateOrderLimit

Create a new cachable limit order that can be used in multiple future requests

CachableMarginRequest order = CacheClientMargin.CreateMarginOrderLimit();

CreateOrderMarket

Create a new cachable market order that can be used in multiple future requests

CachableMarginRequest order = CacheClientMargin.CreateMarginOrderMarket();

POST PlaceOrderMarginCached

Place a Margin Order from data that can be cached

CachableHttpRequestMessagePost request = CacheClient.CreatePostRequestAddAuth(ref restClient);

CachableMarginRequest order = CacheClientMargin.CreateMarginOrderMarket(symbolName, orderSide, orderQuantity, recvWindow);

RestResult<BinancePlacedOrderMargin> result = restClient.Margin.Order.PlaceOrderMargin(ref order, ref request);

Place a Margin Order from data that can be cached and also return a copy of the raw response

RestResultRaw<BinancePlacedOrderMargin> result = restClient.Margin.Order.PlaceOrderMarginRaw(ref order, ref request);

GET GetMarginAccountOrder

Retrieves data for a specific margin account order.

Either orderId or origClientOrderId should be provided.

restClient.Margin.Order.GetMarginAccountOrder();

GET GetMarginAccountOrders

Gets all margin account orders for the provided symbol

restClient.Margin.Order.GetMarginAccountOrders();

GET GetMarginAccountOpenOrders

Gets a list of open margin account orders

restClient.Margin.Order.GetMarginAccountOpenOrders();

GET GetMarginAccountUserTrades

Gets all user margin account trades for provided symbol

restClient.Margin.Order.GetMarginAccountUserTrades();

DELETE CancelMarginOrder

Cancel an active order for margin account

restClient.Margin.Order.CancelMarginOrder();

DELETE CancelOpenMarginOrders

Cancel all active orders for a symbol

restClient.Margin.Order.CancelOpenMarginOrders();

Account Endpoints

General

Get GetAccountInfo

Gets the account information, including balances

restClient.General.GetAccountInfo();

Get GetAccountStatus

Gets the status of the account associated with the api key/secret

restClient.General.GetAccountStatus();

Get GetDailySpotAccountSnapshot

Get a daily account snapshot (balances)

restClient.General.GetDailySpotAccountSnapshot();

Margin

POST Transfer

Execute transfer between spot account and cross margin account.

restClient.Margin.System.Transfer();

Get GetMarginAccountInfo

Query margin account details

restClient.Margin.System.GetMarginAccountInfo();

Get GetMarginLevelInformation

Get personal margin level information for your account

restClient.Margin.System.GetMarginLevelInformation();

Get GetTransferHistory

Get history of transfers

restClient.Margin.System.GetTransferHistory();

Get GetForceLiquidationHistory

Get history of forced liquidations

restClient.Margin.System.GetForceLiquidationHistory();

Get GetMaxTransferAmount

Query max transfer-out amount

restClient.Margin.System.GetMaxTransferAmount();

Isolated

POST EnableIsolatedMarginAccount

Enable an isolated margin account

restClient.Margin.System.EnableIsolatedMarginAccount();

Get GetIsolatedMarginAccount

Isolated margin account info

restClient.Margin.System.GetIsolatedMarginAccount();

Get GetEnabledIsolatedMarginAccountLimit

Get max number of enabled isolated margin accounts

restClient.Margin.System.GetEnabledIsolatedMarginAccountLimit();

Get GetInterestIsolatedMarginData

Get interest isolated margin data

restClient.Margin.System.GetInterestIsolatedMarginData();

DELETE DisableIsolatedMarginAccount

Disable an isolated margin account

restClient.Margin.System.DisableIsolatedMarginAccount();

Lending Endpoints

POST Borrow

Borrow. Apply for a loan.

restClient.Lending.Borrow();

POST Repay

Repay loan for margin account.

restClient.Lending.Repay();

Get GetLoans

Query loan records

restClient.Lending.GetLoans();

Get GetRepays

Query repay records

restClient.Lending.GetRepays();

Get GetMaxBorrowAmount

Query max borrow amount

restClient.Lending.GetMaxBorrowAmount();

Get GetInterestHistory

Get history of interest

restClient.Lending.GetInterestHistory();

Get GetInterestRateHistory

Get history of interest rates

restClient.Lending.GetInterestRateHistory();

Get GetInterestMarginData

Get interest margin data

restClient.Lending.GetInterestMarginData();

Market Endpoints

Spot

GET GetTicker

Get data regarding the last 24 hours for the provided symbol

restClient.Spot.Market.GetTicker();

GET GetTickers

Get data regarding the last 24 hours for all symbols

restClient.Spot.Market.GetTickers();

GET 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();

GET GetCurrentAvgPrice

Gets current average price for a symbol

restClient.Spot.Market.GetCurrentAvgPrice();

GET GetKlines

Get candlestick data for the provided symbol

restClient.Spot.Market.GetKlines();

GET GetTradeHistory

Gets the historical trades for a symbol

restClient.Spot.Market.GetTradeHistory();

GET GetRecentTradeHistory

Gets the recent trades for a symbol

restClient.Spot.Market.GetRecentTradeHistory();

GET GetBookPrice

Gets the best price/quantity on the order book for a symbol.

restClient.Spot.Market.GetBookPrice();

GET GetAllBookPrices

Gets the best price/quantity on the order book for all symbols.

restClient.Spot.Market.GetAllBookPrices();

GET GetPrice

Gets the price of a symbol

restClient.Spot.Market.GetPrice();

GET GetAllPrices

Get a list of the prices of all symbols

restClient.Spot.Market.GetAllPrices();

GET GetTradeFee

Gets the trade fee for a symbol

restClient.Spot.Market.GetTradeFee();

Margin

GET GetMarginAsset

Get a margin asset

restClient.Margin.Market.GetMarginAsset();

GET GetAllMarginAssets

Get all assets available for margin trading

restClient.Margin.Market.GetAllMarginAssets();

GET GetMarginPair

Get a margin pair

restClient.Margin.Market.GetMarginPair();

GET GetAllMarginPairs

Get all asset pairs available for margin trading

restClient.Margin.Market.GetAllMarginPairs();

GET GetMarginPriceIndex

Get margin price index

restClient.Margin.Market.GetMarginPriceIndex();

Isolated

GET GetIsolatedSymbol

Isolated margin symbol info for a specific symbol

restClient.Margin.Market.GetIsolatedMarginSymbol();

GET GetAllIsolatedSymbols

Isolated margin symbol info for all symbols

restClient.Margin.Market.GetAllIsolatedMarginSymbols();

Userstream Endpoints

Spot

POST 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();

PUT 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();

DELETE StopUserStream

Stops the current user stream

restClient.Spot.UserStream.StopUserStream();

Margin

POST 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();

PUT 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();

DELETE StopUserStream

Close the user stream for the cross margin account

restClient.Margin.UserStream.StopUserStream();

Isolated

POST 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();

PUT 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();

DELETE CloseIsolatedUserStream

Close the user stream for the isolated margin account

restClient.Margin.IsolatedUserStream.StopIsolatedMarginUserStream();

Common Endpoints

POST SetBnbBurnStatus

Sets the status of the BNB burn switch for spot trading and margin interest

restClient.General.SetBnbBurnStatus();

POST DustTransfer

Converts dust (small amounts of) assets to BNB

restClient.General.DustTransfer();

POST GetFundingWallet

Get funding wallet assets

restClient.General.GetFundingWallet();

POST Transfer

Transfers between accounts

restClient.General.Transfer();

GET GetUserCoins

Gets information of coins for a user

restClient.General.GetUserCoins();

GET GetAssetDividendRecords

Get asset dividend records

restClient.General.GetAssetDividendRecords();

GET GetBnbBurnStatus

Gets the status of the BNB burn switch for spot trading and margin interest

restClient.General.GetBnbBurnStatus();

GET GetServerTimeTicks

Get the server time ticks as reported by the binance server

long stt = await ServerTimeClient.GetServerTimeTicks().ConfigureAwait(false);

GET GetDustLog

Gets the history of dust conversions

restClient.General.GetDustLog();

GET GetExchangeInfo

Get's information about the exchange including rate limits and information on the provided symbol or symbols

restClient.Spot.System.GetExchangeInfo();

GET GetSystemStatus

Gets the status of the Binance platform

restClient.Spot.System.GetSystemStatus();

GET Ping

Pings the Binance API

restClient.Spot.System.Ping();

GET GetTradingStatus

Gets the trading status for the current account

restClient.General.GetTradingStatus();

GET GetTransfers

Get universal transfer history

restClient.General.GetTransfers();

Websocket Streams

WSS-maroon User Data Streams

Subscribes to the account update stream. Prior to using this, one of the StartUserStream methods should be called.

socketClient.UserDataStreams.Updates();

WSS-maroon SymbolTickerUpdates

Subscribes to ticker updates stream for a specific symbol

socketClient.Subscribe.SymbolTickerUpdates()

WSS-maroon AggregatedTradeUpdates

Subscribes to the aggregated trades update stream for the provided symbol

socketClient.Subscribe.AggregatedTradeUpdates()

WSS-maroon TradeUpdates

Subscribes to the trades update stream for the provided symbol

socketClient.Subscribe.TradeUpdates()

WSS-maroon KlineUpdates

Subscribes to the candlestick update stream for the provided symbols and intervals

socketClient.Subscribe.KlineUpdates()

WSS-maroon SymbolMiniTickerUpdates

Subscribes to mini ticker updates stream for a specific symbol or symbols

socketClient.Subscribe.SymbolMiniTickerUpdates()

WSS-maroon AllSymbolMiniTickerUpdates

Subscribes to mini ticker updates stream for all symbols

socketClient.Subscribe.AllSymbolMiniTickerUpdates()

WSS-maroon BookTickerUpdates

Subscribes to the book ticker update stream for the provided symbol or symbols

socketClient.Subscribe.BookTickerUpdates()

WSS-maroon AllBookTickerUpdates

Subscribes to the book ticker update stream for all symbols

socketClient.Subscribe.AllBookTickerUpdates()

WSS-maroon SymbolTickerUpdates

Subscribes to ticker updates stream for a specific symbol or symbols

socketClient.Subscribe.SymbolTickerUpdates()

WSS-maroon AllSymbolTickerUpdates

Subscribes to ticker updates stream for all symbols

socketClient.Subscribe.AllSymbolTickerUpdates()

EXAMPLE Reconnect Stream

SocketClientHost example = socketClient.Subscribe.SymbolMiniTickerUpdates(...);
example.ReconnectSocket();

EXAMPLE Destroy Stream

SocketClientHost example = socketClient.Subscribe.SymbolMiniTickerUpdates(...);
example.DestroySocket();

EXAMPLE Socket Status

SocketClientHost example = socketClient.Subscribe.SymbolMiniTickerUpdates(...);
example.ConnectionStatusChanged += BinanceSocket_StatusChanged;
private static void BinanceSocket_StatusChanged(ConnectionStatus obj);

Copyright S Christison ©2020-2024

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0.3.1 59 4/16/2024
16.0.0.7 704 9/24/2023

This update
-----
Update BinanceObjects package to v1.0.7.3

Recent
-----
Add BinanceStreamBalanceDelta user data update to websocket streams
Add more overloads for User Data Stream Updates

Remove an old lending endpoint
Update BinanceUriCache package to v1.0.2.4
Update High_Resolution_Sleep package to v1.1.2.5
Update AsyncBlocker.NET package to v1.0.1.4