BinanceAPI.NET 35.1.11

dotnet add package BinanceAPI.NET --version 35.1.11
NuGet\Install-Package BinanceAPI.NET -Version 35.1.11
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="35.1.11" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BinanceAPI.NET --version 35.1.11
#r "nuget: BinanceAPI.NET, 35.1.11"
#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=35.1.11

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

EXAMPLE 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.


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


EXAMPLE 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


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

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

EXAMPLE Authentication

Create an Authentication Provider that can be used by multiple Rest Clients

AuthenticationProvider authenticationProvider = new AuthenticationProvider(api_key, api_secret);

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

EXAMPLE 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

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

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

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

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

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

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

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

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

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

Wallet Endpoints

POST GetFundingWallet

Get funding wallet assets

restClient.Wallet.GetFundingWallet();

POST Transfer

Transfers between accounts

restClient.Wallet.Transfer();

POST DustTransfer

Converts dust (small amounts of) assets to BNB

restClient.Wallet.DustTransfer();

GET GetDailySpotAccountSnapshot

Get a daily account snapshot (balances)

restClient.Wallet.GetDailySpotAccountSnapshot();

GET GetAccountStatus

Gets the status of the account associated with the API Key/Secret

restClient.Wallet.GetAccountStatus();

GET GetAccountInfo

Gets the account information, including balances

restClient.Wallet.GetAccountInfo();

GET GetUserCoins

Get information for all coins for a user

restClient.Wallet.GetUserCoins();

GET GetUserAsset

Get information for a single user asset, positive results only

restClient.Wallet.GetUserAsset();

GET GetAssetDividendRecords

Get asset dividend records

restClient.Wallet.GetAssetDividendRecords();

GET GetDustLog

Gets the history of dust conversions

restClient.Wallet.GetDustLog();

GET GetTradingStatus

Gets the trading status for the current account

restClient.Wallet.GetTradingStatus();

GET GetDepositAddress

Fetch deposit address with network.

restClient.Wallet.GetDepositAddress();

Account Endpoints

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

General Endpoints

POST SetBnbBurnStatus

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

restClient.General.SetBnbBurnStatus();

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.

You should probably use ServerTimeClient.ServerTimeTicks instead.

long? stt = ServerTimeClient.GetServerTimeTicks();

GET GetExchangeInfo

Gets 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 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.SymbolTickerUpdates()

WSS-maroon AggregatedTradeUpdates

Subscribes to the aggregated trades update stream for the provided symbol

socketClient.AggregatedTradeUpdates()

WSS-maroon TradeUpdates

Subscribes to the trades update stream for the provided symbol

socketClient.TradeUpdates()

WSS-maroon RealTimeLastPriceUpdates

Subscribes to real time last price information for a symbol

socketClient.RealTimeLastPriceUpdates()

WSS-maroon KlineUpdates

Subscribes to the candlestick update stream for the provided symbols and intervals, UTC+0 Day

socketClient.KlineUpdates()

WSS-maroon 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()

WSS-maroon SymbolMiniTickerUpdates

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

socketClient.SymbolMiniTickerUpdates()

WSS-maroon AllSymbolMiniTickerUpdates

Subscribes to mini ticker updates stream for all symbols

socketClient.AllSymbolMiniTickerUpdates()

WSS-maroon BookTickerUpdates

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

socketClient.BookTickerUpdates()

WSS-maroon AllBookTickerUpdates

Subscribes to the book ticker update stream for all symbols

socketClient.AllBookTickerUpdates()

WSS-maroon SymbolTickerUpdates

Subscribes to ticker updates stream for a specific symbol or symbols

socketClient.SymbolTickerUpdates()

WSS-maroon AllSymbolTickerUpdates

Subscribes to ticker updates stream for all symbols

socketClient.AllSymbolTickerUpdates()

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

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
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