BingX.Net
BingX.Net is a client library for accessing the BingX REST and Websocket API. All data is mapped to readable models and enum values. Additional features include an implementation for maintaining a client side order book, easy integration with other exchange client libraries and more.
Supported Frameworks
The library is targeting both .NET Standard 2.0
and .NET Standard 2.1
for optimal compatibility
.NET implementation | Version Support |
---|---|
.NET Core | 2.0 and higher |
.NET Framework | 4.6.1 and higher |
Mono | 5.4 and higher |
Xamarin.iOS | 10.14 and higher |
Xamarin.Android | 8.0 and higher |
UWP | 10.0.16299 and higher |
Unity | 2018.1 and higher |
Discord
A Discord server is available here. Feel free to join for discussion and/or questions around the CryptoExchange.Net and implementation libraries.
Support the project
DonateMake a one time donation in a crypto currency of your choice. If you prefer to donate a currency not listed here please contact me.
Btc: bc1q277a5n54s2l2mzlu778ef7lpkwhjhyvghuv8qf
Eth: 0xcb1b63aCF9fef2755eBf4a0506250074496Ad5b7
USDT (TRX): TKigKeJPXZYyMVDgMyXxMf17MWYia92Rjd
Alternatively, sponsor me on Github using Github Sponsors.
Getting Started
The packge is available on Nuget. After installing the package the BingX API is available by using the BingXRestClient
and BingXSocketClient
.
Installation
Add the package via dotnet, or add it via the package manager.
dotnet add package JK.BingX.Net
API Access
BingX.Net can be configured using Dotnet dependency injection, after which the clients can be injected into your services. It also correctly configures logging and HttpClient usage.
builder.Services.AddBingX(options => {
// Options can be configured here, for example:
options.ApiCredentials = new ApiCredentials("APIKEY", "APISECRET");
});
The IBingXRestClient
and IBingXSocketClient
can then be injected.
Alternatively the rest and socket client can be constructed directly
var restClient = new BingXRestClient(options => {
// Options can be configured here, for example:
options.ApiCredentials = new ApiCredentials("APIKEY", "APISECRET");
});
var socketClient = new BingXSocketClient();
Examples
Spot API
Get SymbolsGet a list of supported spot symbols
var bingXClient = new BingXRestClient();
var result = await bingXClient.SpotApi.ExchangeData.GetSymbolsAsync();
Console.WriteLine(result.Data.First());
Get Symbol TickerGet the 24h price ticker of a spot symbol
var bingXClient = new BingXRestClient();
var result = await bingXClient.SpotApi.ExchangeData.GetTickersAsync("ETH-USDT");
Console.WriteLine(result.Data.First());
Get Recent TradesGet the most recent trades for a spot symbol
var bingXClient = new BingXRestClient();
var result = await bingXClient.SpotApi.ExchangeData.GetRecentTradesAsync("ETH-USDT");
Console.WriteLine(result.Data.First());
Get BalancesGet asset balances of the spot account
var bingXClient = new BingXRestClient(options => {
options.ApiCredentials = new ApiCredentials("KEY", "SECRET");
});
var result = await bingXClient.SpotApi.Account.GetBalancesAsync();
Console.WriteLine(result.Data.First());
Place Limit OrderPlace a new limit order for buying 0.1 ETH at a price of 2000 USDT
var bingXClient = new BingXRestClient(options => {
options.ApiCredentials = new ApiCredentials("KEY", "SECRET");
});
var result = await bingXClient.SpotApi.Trading.PlaceOrderAsync(
"ETH-USDT",
BingX.Net.Enums.OrderSide.Buy,
BingX.Net.Enums.OrderType.Limit,
0.1m,
2000);
Console.WriteLine(result.Data);
Place Market OrderPlace a new market order for buying 50 USDT worth of ETH at the best available price
var bingXClient = new BingXRestClient(options => {
options.ApiCredentials = new ApiCredentials("KEY", "SECRET");
});
var result = await bingXClient.SpotApi.Trading.PlaceOrderAsync(
"ETH-USDT",
BingX.Net.Enums.OrderSide.Buy,
BingX.Net.Enums.OrderType.Market,
quoteQuantity: 50);
Console.WriteLine(result.Data);
Get Order InfoRetrieve order information for a specific order
var bingXClient = new BingXRestClient(options => {
options.ApiCredentials = new ApiCredentials("KEY", "SECRET");
});
var result = await bingXClient.SpotApi.Trading.GetOrderAsync("ETH-USDT", 123);
Console.WriteLine(result.Data);
Cancel an orderCancel a currently active order
var bingXClient = new BingXRestClient(options => {
options.ApiCredentials = new ApiCredentials("KEY", "SECRET");
});
var result = await bingXClient.SpotApi.Trading.CancelOrderAsync("ETH-USDT", 123);
Console.WriteLine(result.Data);
Futures API
Get ContractsGet a list of supported perpetual futures contracts
var bingXClient = new BingXRestClient();
var result = await bingXClient.PerpetualFuturesApi.ExchangeData.GetContractsAsync();
Console.WriteLine(result.Data.First());
Get Symbol TickerGet the 24h price ticker of a futures symbol
var bingXClient = new BingXRestClient();
var result = await bingXClient.PerpetualFuturesApi.ExchangeData.GetTickerAsync("ETH-USDT");
Console.WriteLine(result.Data.First());
Get Recent TradesGet the most recent trades for a futures symbol
var bingXClient = new BingXRestClient();
var result = await bingXClient.PerpetualFuturesApi.ExchangeData.GetRecentTradesAsync("ETH-USDT");
Console.WriteLine(result.Data.First());
Get BalancesGet balance of the perpetual futures account
var bingXClient = new BingXRestClient(options => {
options.ApiCredentials = new ApiCredentials("KEY", "SECRET");
});
var result = await bingXClient.PerpetualFuturesApi.Account.GetBalancesAsync();
Console.WriteLine(result.Data);
Get PositionsGet open positions
var bingXClient = new BingXRestClient(options => {
options.ApiCredentials = new ApiCredentials("KEY", "SECRET");
});
var result = await bingXClient.PerpetualFuturesApi.Account.GetPositionsAsync();
Console.WriteLine(result.Data.First());
Place Limit OrderPlace a new limit order for going long on 0.1 ETH at a price of 2000 USDT
var bingXClient = new BingXRestClient(options => {
options.ApiCredentials = new ApiCredentials("KEY", "SECRET");
});
var result = await bingXClient.PerpetualFuturesApi.Trading.PlaceOrderAsync(
"ETH-USDT",
BingX.Net.Enums.OrderSide.Buy,
BingX.Net.Enums.FuturesOrderType.Limit,
BingX.Net.Enums.PositionSide.Long,
0.1m,
2000);
Console.WriteLine(result.Data);