BinanceAPI.NET
35.1.11
dotnet add package BinanceAPI.NET --version 35.1.11
NuGet\Install-Package BinanceAPI.NET -Version 35.1.11
<PackageReference Include="BinanceAPI.NET" Version="35.1.11" />
paket add BinanceAPI.NET --version 35.1.11
#r "nuget: BinanceAPI.NET, 35.1.11"
// Install BinanceAPI.NET as a Cake Addin
#addin nuget:?package=BinanceAPI.NET&version=35.1.11
// Install BinanceAPI.NET as a Cake Tool
#tool nuget:?package=BinanceAPI.NET&version=35.1.11
High Performance Rest API/Websocket Wrapper for Binance.com
Provides the fastest possible access to the Binance Rest API
/User Data Streams
and Websocket Market Streams
with an emphasis on creating requests quickly and caching data when possible so requests are more responsive, This library is the best option if you want to trade Spot
or Margin
.
Please use the Contact Form
if you would like to request an endpoint, ask a specific question or report an issue
Full Example
and Documentation
below.
Cachable Requests
Caching
allows you to prepare requests Ahead of Time
based on changes on the UI
or other factors
You can use these objects as they are in some scenarios or you can use them to make a fully functional Cache
// This is a common scenario where a `Cached Request` is updated based on a `Setter` for a `Control`
CachableSpotRequestPartialMarket CachableMarketOrderPartial = CacheClientSpot.CreateOrderMarketPartial("Symbol", OrderSide.Buy, 1000); // init
private string CompletedRequest = string.Empty;
public decimal QuoteQuantity
{
get => quoteQuantity;
set
{
quoteQuantity = value;
CompletedRequest = CachableMarketOrderPartial.Complete(value, true); // complete/update
Set();
}
}
// Later on Click etc
restClient.Spot.Order.PlaceOrderSpot(ref CompletedRequest);
Object Generators
Generators
are how the library turns JSON
back into Strongly Typed Objects
without requiring any external dependencies.
This is done for you automatically and is a lot faster.
Some endpoints also return the Raw Response
and all Generators
are available for use in that case.
string websocketData = "" +
"{" +
"\"id\":\"4\"," +
"\"status\":200," +
"\"result\":" +
"[[1712372100000,\"702.60000000\",\"702.80000000\",\"697.60000000\",\"699.60000000\",\"1634.78800000\",1712372399999,\"1144306.51160000\",2221,\"499.69000000\",\"349791.43160000\",\"0\"]," +
"[1712372400000,\"699.60000000\",\"701.60000000\",\"696.80000000\",\"700.90000000\",\"2092.67500000\",1712372699999,\"1463135.03660000\",2371,\"1033.37300000\",\"722800.30360000\",\"0\"]]" +
"}";
List<BinanceKline>? websocketTest = BinanceKlineGenerator.CreateEnumerableArrayResult(websocketData);
Generators
can be found by adding the word Generator
to the end of a Type
Raw Responses
should be saved to file without modifications so they can be Generated
later
ObjectGenerator.NET
is available for use in projects that don't include this library, You can get it Here
Simple Automation Demonstration
Automates modifying the last open order or creating a new open order with a specified PnL
// Please make sure you understand before you run this example.
// This example is solely intended to demonstrate how to use various aspects of the library.
// I am not responsible for your usage of this functional example.
// Command Line Arguments
// MODE - create new/add last, eg. true
// SYMBOL - symbol name, eg. 1000SATSUSDT
// ASSET - symbol asset, eg. 1000SATS
// QUOTE - quote quantity, eg. 1 USDT
// PERCENT - pnl percent, eg. 0.4%
// eg.
// SimpleExample.exe true 1000SATSUSDT 1000SATS 1 0.4 // Create new with PnL Percent
// SimpleExample.exe false 1000SATSUSDT 1000SATS 1 // Add to Last Open Order
using BinanceAPI;
using BinanceAPI.Authentication;
using BinanceAPI.Enums;
using BinanceAPI.Hosts;
using BinanceAPI.MarketData;
using BinanceAPI.Rest;
using BinanceAPI.SharedObjects;
using BinanceAPI.SpotData;
using BinanceAPI.UserData;
using BinanceAPI.UserStream;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace FullRestExample
{
internal class Program
{
private const int RECV_WINDOW = 2000;
private static decimal QuoteQunatity = 1; // eg. 1 USDT
private static decimal PnlPercent = 0.4m; // eg. 0.4%
private static string Symbol = "symbol"; // eg. 1000SATSUSDT
private static string Asset = "asset"; // eg. 1000SATS
private static RestClient RestClient = null!;
private static SocketClient SocketClient = null!;
private static UserDataUpdate UserDataUpdate = null!;
private static AuthenticationProvider AuthenticationProvider = null!;
private static CachableSpotRequest AdjustMarketOrder = null!;
private static CachableSpotRequestPartial CachableSpotRequestPartial = null!;
private static BinanceSymbol? BinanceSymbol = null!;
private static decimal QuantityStepSize;
private static byte QuantityStepSizeScale;
private static int PriceTickScale;
private static bool createNewMode = false;
private static volatile int singleEntry = 0;
public static decimal AvailableN = decimal.Zero;
private static readonly Action<BinanceStreamPositionsUpdate?> PositionUpdateAction = (message) =>
{
if (message != null)
{
foreach (var position in message.Balances)
{
if (position.Asset == Asset)
{
AvailableN = position.Free.Scale(QuantityStepSizeScale);
}
}
}
UserDataUpdate.Signal();
};
private static void Main(string[] args)
{
SetupConsole();
if (CheckArgumentsValid(args))
{
AdjustMarketOrder = CacheClientSpot.CreateOrderMarketQuote(Symbol, OrderSide.Buy, QuoteQunatity, RECV_WINDOW);
CachableSpotRequestPartial = CacheClientSpot.CreateOrderLimitPartial(Symbol, OrderSide.Sell, OrderType.Limit, RECV_WINDOW, TimeInForce.GoodTillCancel, OrderResponseType.ACK);
AuthenticationProvider = new("YOUR HMAC API KEY", "YOUR HMAC API SECRET KEY");
RestClient = new RestClient(AuthenticationProvider, RestClientOptions);
SocketClient = new SocketClient();
BinanceSymbol = RestClient.Spot.System.GetExchangeInfo(Symbol).Data?.Symbols.FirstOrDefault();
UserDataUpdate = new UserDataUpdate(SocketClient, RestClient, PositionUpdateAction);
if (BinanceSymbol != null)
{
QuantityStepSize = BinanceSymbol.LotSizeFilter?.StepSize ?? decimal.Zero;
QuantityStepSizeScale = new DecimalHelper(QuantityStepSize.Normalize()).Scale;
PriceTickScale = new DecimalHelper(BinanceSymbol.PriceFilter?.TickSize.Normalize() ?? 1).Scale;
Console.WriteLine("Server Time Ticks: " + ServerTimeClient.ServerTimeTicks);
if (ServerTimeClient.ServerTimeTicks > 0)
{
Console.WriteLine("--------CLOSE APPLICATION TO STOP--------");
WaitForInputLoop();
}
else
{
Console.WriteLine("--------NETWORK ERROR--------");
}
}
else
{
Console.WriteLine("Exchange Information Not Found for: " + Symbol);
}
}
WaitCleanupConsole();
}
private static void WaitForInputLoop()
{
if (createNewMode)
{
Console.WriteLine("Press any key to:\n1. Buy [" + QuoteQunatity + " USDT] of [" + Symbol + "]\n2. Create a new order with pnl of [" + PnlPercent + "%]");
}
else
{
Console.WriteLine("Press any key to:\n1. Buy [" + QuoteQunatity + " USDT] of [" + Symbol + "]\n2. Add the quantity to the last open order");
}
while (true)
{
Console.ReadLine();
if (Interlocked.Exchange(ref singleEntry, 1) == 0)
{
if (!createNewMode)
{
ThreadPool.UnsafeQueueUserWorkItem((_) =>
{
RestResult<List<BinanceOrderSpot>> openOrders = RestClient.Spot.Order.GetOpenOrders(Symbol);
if (openOrders.Data != null)
{
int openOrderCount = openOrders.Data.Count() - 1;
if (openOrderCount >= 0)
{
BinanceOrderSpot lastOrder = openOrders.Data.ElementAtOrDefault(openOrderCount);
if (lastOrder != null)
{
if (AdjustOrder(ref lastOrder))
{
Console.WriteLine("OKAY");
Interlocked.Exchange(ref singleEntry, 0);
return;
}
}
}
}
Console.WriteLine("FAILED");
Interlocked.Exchange(ref singleEntry, 0);
}, null);
}
else
{
ThreadPool.UnsafeQueueUserWorkItem((_) =>
{
if (AddOrder())
{
Console.WriteLine("OKAY");
}
else
{
Console.WriteLine("FAILED");
}
Interlocked.Exchange(ref singleEntry, 0);
}, null);
}
}
else
{
Console.WriteLine("Still waiting for last request");
}
}
}
private static bool AddOrder()
{
RestResult<BinancePlacedOrderSpot> addOrder = RestClient.Spot.Order.PlaceOrderSpot(ref AdjustMarketOrder);
if (addOrder.Data != null)
{
UserDataUpdate.WaitForUpdate();
if (AvailableN >= QuantityStepSize)
{
string completedRequest = CachableSpotRequestPartial.Complete((addOrder.Data.Price + (addOrder.Data.Price / 100 * PnlPercent)).Scale(PriceTickScale), AvailableN);
RestResult<BinancePlacedOrderSpot> newOrder = RestClient.Spot.Order.PlaceOrderSpot(ref completedRequest);
if (newOrder.Data != null)
{
AvailableN = decimal.Zero;
return true;
}
else
{
Error(newOrder.Error, "New Order");
}
}
else
{
Console.WriteLine("Invalid Available Amount");
}
}
else
{
Error(addOrder.Error, "Adjust Order");
}
AvailableN = decimal.Zero;
return false;
}
private static bool AdjustOrder(ref BinanceOrderSpot bos)
{
RestResult<BinancePlacedOrderSpot> adjustOrder = RestClient.Spot.Order.PlaceOrderSpot(ref AdjustMarketOrder);
if (adjustOrder.Data != null)
{
RestResult<BinanceCancelledId> cancelled = RestClient.Spot.Order.CancelOrder(Symbol, bos.OrderId);
if (cancelled.Data != null)
{
UserDataUpdate.WaitForUpdate();
if (AvailableN >= QuantityStepSize)
{
decimal pricePercent = bos.Price / 100 * PnlPercent;
decimal lastPriceNegative = bos.Price - pricePercent;
string req = CachableSpotRequestPartial.Complete((adjustOrder.Data.Price <= lastPriceNegative ? bos.Price : bos.Price + pricePercent).Scale(PriceTickScale), AvailableN);
RestResult<BinancePlacedOrderSpot> newOrder = RestClient.Spot.Order.PlaceOrderSpot(ref req);
if (newOrder.Data != null)
{
AvailableN = decimal.Zero;
return true;
}
else
{
Error(newOrder.Error, "New Order");
}
}
else
{
Console.WriteLine("Invalid Available Amount");
}
}
else
{
Error(cancelled.Error, "Cancelled");
}
}
else
{
Error(adjustOrder.Error, "Adjust Order");
}
AvailableN = decimal.Zero;
return false;
}
private static void Error(RestError? error, string location)
{
if (error != null)
{
if (error.Exception != null)
{
Console.WriteLine("Exception " + location + " | " + error.Exception.Message);
}
else
{
Console.WriteLine("Error " + location + " | " + error.ErrorMessage);
}
}
}
private static bool CheckArgumentsValid(string[] args)
{
bool success = false;
if (args.Length > 0)
{
if (args[0] == "true")
{
if (args.Length == 5)
{
createNewMode = true;
try
{
Symbol = args[1];
Asset = args[2];
QuoteQunatity = decimal.Parse(args[3]);
PnlPercent = decimal.Parse(args[4]);
success = true;
}
catch
{
success = false;
}
}
}
else if (args[0] == "false")
{
if (args.Length == 4)
{
try
{
Symbol = args[1];
Asset = args[2];
QuoteQunatity = decimal.Parse(args[3]);
success = true;
}
catch
{
success = false;
}
}
}
}
if (!success)
{
Console.WriteLine("Invalid Argument, Fix and Restart\n\nValid Examples:\n\nAdd to Last Open Order\nSimpleExample.exe false 1000SATSUSDT 1000SATS 1\n\nCreate new with PnL Percent\nSimpleExample.exe true 1000SATSUSDT 1000SATS 1 0.4");
}
return success;
}
// ---------------------------------
private static void SetupConsole()
{
Console.CursorVisible = false;
Console.WindowWidth = (int)(Console.LargestWindowWidth / 2.5);
Console.WindowHeight = (int)(Console.LargestWindowHeight / 2.5);
}
private static void WaitCleanupConsole()
{
Console.ReadLine();
Console.WriteLine("Cleaning up.. Please wait..");
RestClient.Dispose();
UserDataUpdate.Dispose();
Console.WriteLine("Press any key to exit");
Console.ReadLine();
}
private static readonly RestClientOptions RestClientOptions = new()
{
SyncUpdateTime = 5,
GetCacheSize = 2048,
PutCacheSize = 2048,
PostCacheSize = 2048,
DeleteCacheSize = 2048,
ReceiveWindow = TimeSpan.FromMilliseconds(RECV_WINDOW),
DefaultApiController = BinanceApiController.DEFAULT
};
}
public class UserDataUpdate
{
public volatile int Waiting = 0;
private readonly SocketClientHost SocketClientHost = null!;
public UserDataUpdate(SocketClient socketClient, RestClient restCLient, Action<BinanceStreamPositionsUpdate?> onPositionUpdate)
{
RestResult<BinanceListenKey> listenKey = restCLient.Spot.UserStream.StartUserStream();
if (listenKey.Data != null)
{
SocketClientHost = socketClient.UserDataStreams.Updates(listenKey.Data.ListenKey, null, (positionUpdate) => { onPositionUpdate(positionUpdate); });
}
}
public void Signal()
{
Interlocked.Exchange(ref Waiting, 0);
}
public void WaitForUpdate()
{
Interlocked.Exchange(ref Waiting, 1);
while (Waiting == 1)
{
Delay.Wait(50);
}
}
public void Dispose()
{
SocketClientHost?.Dispose();
}
}
}
Simple Ticker Example
Subscribe to Real Time LastPrice Updates
for a particular symbol
using BinanceAPI;
using BinanceAPI.Hosts;
namespace FullSocketExample
{
public class LastPriceTicker
{
private readonly SocketClientHost TickerHost;
public decimal LastPrice = decimal.Zero;
public LastPriceTicker(string symbol, ref RestClient restClient, ref SocketClient socketClient)
{
LastPrice = restClient.Spot.Market.GetPrice(symbol).Data?.Price ?? decimal.Zero;
TickerHost = socketClient.RealTimeLastPriceUpdates(symbol, (update) =>
{
if (update != null)
{
LastPrice = update.LastPrice;
}
});
}
public void Dispose()
{
TickerHost.DestroySocket();
TickerHost.Dispose();
}
}
}
Authentication
Create an Authentication Provider
that can be used by multiple Rest Clients
AuthenticationProvider authenticationProvider = new AuthenticationProvider(api_key, api_secret);
Create Rest Client
Change the Rest Client Options
and create a new Rest Client
using the Authentication Provider
above
RestClientOptions restClientOptions = new()
{
SyncUpdateTime = 5,
GetCacheSize = 2048,
PutCacheSize = 2048,
PostCacheSize = 2048,
DeleteCacheSize = 2048,
ReceiveWindow = TimeSpan.FromMilliseconds(1000),
DefaultApiController = BinanceApiController.DEFAULT
};
RestClient restClient = new RestClient(authenticationProvider, restClientOptions, CancellationToken.None);
Create Socket Client
Create a Socket Client
that can be used to Connect/Subscribe
to Websocket Streams
Returns a SocketClientHost
that can be used to manage the connection.
SocketClient socketClient = new SocketClient(50);
SocketClientHost example = socketClient.SymbolMiniTickerUpdates(...);
example.ConnectionStatusChanged += BinanceSocket_StatusChanged;
example.ReconnectSocket();
example.DestroySocket();
50
is the default number of Reconnect Attempts
before the socket will Fail
Server Time Client
The Server Time Client
is used to produce high quality Timestamps
for requests by guessing the Server Time
Get Server Time
The current Server Time Guess
according to the Server Time Client
You can use this Timestamp
for comparisons anywhere in your application
ServerTimeClient.ServerTimeTicks
Order Endpoints
Spot Orders
CreateOrderLimit
Create a new cachable limit order that can be used in multiple future requests
This object can be cached and reused
CachableSpotRequest order = CacheClientSpot.CreateOrderLimit();
CreateOrderMarket
Create a new cachable market order that can be used in multiple future requests
This object can be cached and reused
CachableSpotRequest order = CacheClientSpot.CreateOrderMarket();
CachableSpotRequest order = CacheClientSpot.CreateOrderMarketQuote();
PlaceOrderSpotCached
Place a Spot Order
from data that can be cached
CachableSpotRequest order = CacheClientSpot.CreateOrderMarket(symbolName, orderSide, orderQuantity, recvWindow);
RestResult<BinancePlacedOrderSpot> result = restClient.Spot.Order.PlaceOrderSpot(ref order, CancellationToken.None);
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, default);
PlaceTestOrder
Places a new test order.
Test orders are not actually being executed and just test the functionality.
CachableSpotRequest spotRequest = CacheClientSpot.CreateOrderMarket("BTCUSDT", OrderSide.Sell, 1, 1000);
RestResult<BinancePlacedOrderSpot> result = restClient.Spot.Order.PlaceTestOrder(ref spotRequest, default);
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 Orders
CreateOrderLimit
Create a new cachable limit order that can be used in multiple future requests
This object can be cached and reused
CachableMarginRequest order = CacheClientMargin.CreateMarginOrderLimit();
CreateOrderMarket
Create a new cachable market order that can be used in multiple future requests
This object can be cached and reused
CachableMarginRequest order = CacheClientMargin.CreateMarginOrderMarket();
CachableMarginRequest order = CacheClientMargin.CreateMarginOrderMarketQuote();
PlaceOrderMarginCached
Place a Margin Order
from data that can be cached
CachableMarginRequest order = CacheClientMargin.CreateMarginOrderMarket(symbolName, orderSide, orderQuantity, recvWindow);
RestResult<BinancePlacedOrderMargin> result = restClient.Margin.Order.PlaceOrderMargin(ref order, CancellationToken.None);
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, default);
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();
Wallet Endpoints
GetFundingWallet
Get funding wallet assets
restClient.Wallet.GetFundingWallet();
Transfer
Transfers between accounts
restClient.Wallet.Transfer();
DustTransfer
Converts dust (small amounts of) assets to BNB
restClient.Wallet.DustTransfer();
GetDailySpotAccountSnapshot
Get a daily account snapshot (balances)
restClient.Wallet.GetDailySpotAccountSnapshot();
GetAccountStatus
Gets the status of the account associated with the API Key/Secret
restClient.Wallet.GetAccountStatus();
GetAccountInfo
Gets the account information, including balances
restClient.Wallet.GetAccountInfo();
GetUserCoins
Get information for all coins for a user
restClient.Wallet.GetUserCoins();
GetUserAsset
Get information for a single user asset, positive results only
restClient.Wallet.GetUserAsset();
GetAssetDividendRecords
Get asset dividend records
restClient.Wallet.GetAssetDividendRecords();
GetDustLog
Gets the history of dust conversions
restClient.Wallet.GetDustLog();
GetTradingStatus
Gets the trading status for the current account
restClient.Wallet.GetTradingStatus();
GetDepositAddress
Fetch deposit address with network.
restClient.Wallet.GetDepositAddress();
Account Endpoints
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();
General Endpoints
SetBnbBurnStatus
Sets the status of the BNB
burn switch for spot trading and margin interest
restClient.General.SetBnbBurnStatus();
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.
You should probably use ServerTimeClient.ServerTimeTicks
instead.
long? stt = ServerTimeClient.GetServerTimeTicks();
GetExchangeInfo
Gets 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();
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.SymbolTickerUpdates()
AggregatedTradeUpdates
Subscribes to the aggregated trades update stream for the provided symbol
socketClient.AggregatedTradeUpdates()
TradeUpdates
Subscribes to the trades update stream for the provided symbol
socketClient.TradeUpdates()
RealTimeLastPriceUpdates
Subscribes to real time last price information for a symbol
socketClient.RealTimeLastPriceUpdates()
KlineUpdates
Subscribes to the candlestick update stream for the provided symbols and intervals, UTC+0 Day
socketClient.KlineUpdates()
KlineUpdatesUtc8
Subscribes to the candlestick update stream for the provided symbols and intervals, UTC+8 Day
Note that Event Time
, Start Time
and Close Time
are always in UTC+0
.
socketClient.KlineUpdatesUtc8()
SymbolMiniTickerUpdates
Subscribes to mini ticker updates stream for a specific symbol or symbols
socketClient.SymbolMiniTickerUpdates()
AllSymbolMiniTickerUpdates
Subscribes to mini ticker updates stream for all symbols
socketClient.AllSymbolMiniTickerUpdates()
BookTickerUpdates
Subscribes to the book ticker update stream for the provided symbol or symbols
socketClient.BookTickerUpdates()
AllBookTickerUpdates
Subscribes to the book ticker update stream for all symbols
socketClient.AllBookTickerUpdates()
SymbolTickerUpdates
Subscribes to ticker updates stream for a specific symbol or symbols
socketClient.SymbolTickerUpdates()
AllSymbolTickerUpdates
Subscribes to ticker updates stream for all symbols
socketClient.AllSymbolTickerUpdates()
Donate
Donating supports development and is a great way to say Thank You
People who donate get priority when responding to questions submitted via the Contact Form
Coin | Address |
---|---|
BTC | 1NXUg88UvRWYn1WTnikVNn2fbbEtuTeXzm |
LTC | Lbd3oMKeokyXUQaxBDJpMMNVUws5wYhQES |
ETH | 0x88d381c089565970e317de7290846ca7cf84cec5 |
DOGE | DS6orKQwdK4sBTmwoS9NVqvWCKA5ksGPfa |
If you want to donate something not listed here please use the Contact Form
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
- High_Resolution_Sleep (>= 2.0.0.11)
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 |
---|---|---|
35.1.11 | 3,636 | 6/18/2024 |
Please use the most recent version visible on Nuget, old versions are hidden but can still be downloaded indirectly
----------------
BTC - 1NXUg88UvRWYn1WTnikVNn2fbbEtuTeXzm
LTC - Lbd3oMKeokyXUQaxBDJpMMNVUws5wYhQES
ETH - 0x88d381c089565970e317de7290846ca7cf84cec5
DOGE - DS6orKQwdK4sBTmwoS9NVqvWCKA5ksGPfa