WARNING This was a submission to the Binance C# API competition. It's not under active development anymore. I suggest a better alternative which is: https://github.com/binance-exchange/BinanceDotNet
This project is a typed client-library for the Binance Exchange API. It makes it easy to integrate Binance API functionality in your application.
You should install BinanceService with NuGet:
Install-Package BinanceService
Or via the .NET Core command line interface:
dotnet add package BinanceService
See the following section for usage examples.
The API is split up into three logical classes mirroring the endpoints exposed by the Binance API.
The market data endpoint can be used anonymously.
var binanceMarketService = new BinanceMarketService();The account endpoint requires authentication using your API key and secret (can be found on the Binance API setting page).
var binanceAccountService = new BinanceAccountService("KEY", "SECRET");The steam-service exposes an easy way to consume the websockets streams in an asynchronous way.
var binanceStream = new BinanceStreamService();The available methods on the classes should be pretty self explanatory and are fully documented. Some examples:
var orderbook = await binanceMarketService.GetOrderBook("NEOBTC");
Console.WriteLine("Orderbook: " + JsonConvert.SerializeObject(orderbook, Formatting.Indented));
var aggTrades = await binanceMarketService.GetAggregateTrades("NEOBTC");
Console.WriteLine("Agg trades: " + JsonConvert.SerializeObject(aggTrades, Formatting.Indented));
var priceStats = await binanceMarketService.GetPriceStats("NEOBTC");
Console.WriteLine("Pricestats: " + JsonConvert.SerializeObject(priceStats, Formatting.Indented));var order = await binanceAccount.PostOrder("NEOBTC", OrderSide.Buy, OrderType.Market, TimeInForce.ImmediateOrCancel, 0.10m, 1, test: true);
Console.WriteLine("Market order: " + JsonConvert.SerializeObject(order, Formatting.Indented));
var myTrades = await binanceAccount.GetTrades("NEOBTC");
Console.WriteLine("My trades: " + JsonConvert.SerializeObject(myTrades, Formatting.Indented));await binanceStream.StreamTrades("NEOBTC", (t) => Console.WriteLine(t.TradeId), cts.Token);Please see the BinanceService.Examples project for more examples.
For more guidance you can also have a look at the official Binance documentation.
- Robert Massa - Initial work - Grepsy
This project is licensed under the MIT License.