Open Source Spotlight: BitMEX.Net Integration

Introducing BitMEX.NET, an open-source C# client library designed to simplify the complexities of interacting with the BitMEX REST and WebSocket APIs.

Open Source Spotlight: BitMEX.Net Integration - featured image

In our commitment to supporting the developer ecosystem, we are excited to introduce BitMEX.Net, a powerful open-source C# client library developed by JKorf. Designed for developers building on the .NET ecosystem, this library simplifies the complexities of interacting with the BitMEX REST and WebSocket APIs, allowing for high-performance trading and real-time data integration.

What is BitMEX.Net?

BitMEX.Net is a client library built on top of the CryptoExchange.Net framework. It provides a strongly-typed, easy-to-use interface for the BitMEX API, mapping raw JSON responses into descriptive C# models and enums. Whether you are building a simple trading bot or a complex high-frequency platform, BitMEX.Net handles the "plumbing" such as authentication, rate limiting, and socket management, so you can focus on your building strategy.

Key Features of BitMEX.Net

  • Comprehensive API Coverage: Full support for BitMEX REST endpoints and WebSocket streams, including market data, order management, and account updates.

  • Strongly Typed Models: All response data is mapped to descriptive C# objects, reducing errors and improving development speed compared to handling raw JSON.

  • Advanced WebSocket Management: Features automatic reconnection, subscription management, and client-side order book implementations to ensure your data stays live and accurate.

  • Client-Side Rate Limiting: Built-in safeguards to help stay within BitMEX API limits, preventing accidental 429 errors and temporary bans.

  • Native AOT Support: Optimised for modern .NET performance, including support for Native Ahead-of-Time (AOT) compilation for ultra-fast startup and execution.

  • Shared Interface Support: As part of the CryptoExchange.Net family, it implements shared interfaces that allow developers to switch between different exchange libraries with minimal code changes.

How to Get Started with BitMEX.Net

The library is available as a NuGet package, making it easy to drop into any .NET project: dotnet add package BitMEX.Net

Example Usage:

// Get the last price for ETH/USDT

var restClient = new BitMEXRestClient();

var tickerResult = await restClient.ExchangeApi.ExchangeData.GetSymbolsAsync("ETHUSDT");

if (tickerResult.Success)

    Console.WriteLine($"Last price: {tickerResult.Data.Single().LastPrice}");

// Example output:

// Last price: 2994,17

// Get available account balances

var client = new BitMEXRestClient(options =>

{

    options.ApiCredentials = new ApiCredentials("[APIKEY]", "[APISECRET]");

});

var balanceResult = await client.ExchangeApi.Account.GetBalancesAsync();

if (balanceResult.Success)

{

    foreach (var balance in balanceResult.Data)

        Console.WriteLine($"{balance.Currency}: {balance.Quantity}");

}

// Example output:

// Gwei: 2000000

// USDt: 18203791

// LAMp: 10500

// XBt: 0

// Subscribe to book ticker updates for XBT/USDT

var socketClient = new BitMEXSocketClient();

var subscribeResult = await socketClient.ExchangeApi.SubscribeToBookTickerUpdatesAsync("XBTUSDT", update =>

{

    Console.WriteLine($"New best bid/ask: {update.Data.BestBidPrice} / {update.Data.BestAskPrice}");

});

// Example output:

// New best bid/ask: 89978,9 / 89981,3

// New best bid/ask: 89978,9 / 89981,4

// New best bid/ask: 89979,0 / 89981,4

// ..

Why Use BitMEX.Net

For developers in the .NET space, BitMEX.Net represents a best-in-class wrapper. It adheres to modern C# standards, offers extensive logging for debugging, and is actively maintained to reflect the latest updates to the BitMEX API.

You can find the full source code, detailed documentation, and contribution guidelines at the official GitHub repository.

To learn more about our other trading partnerships and API tools, visit the BitMEX Partners Page.

If you haven’t signed up for a BitMEX account yet, we’re currently offering $5,050 worth of trading credits to new users - you can register here

To be the first to know about our new listings, product launches, giveaways and more, we invite you to join one of our online communities and connect with other traders. For the absolute latest, you can also follow us on Twitter, or read our blog and site announcements.

In the meantime, if you have any questions please contact Support who are available 24/7.

WRITTEN BY

BitMEX

TAGS

BitMEX.NetC# client libray.NET ecosystemBitMEX API