https://github.com/semashkinvg/bitmex.net
Wrapper for BitMEX.com REST & WebSocket API
https://github.com/semashkinvg/bitmex.net
api-wrapper bitcoin bitcoin-api bitmex bitmex-api cryptocurrency csharp dotnet exchange exchange-api instrument position quotes rest-api trade tradeapi wrapper
Last synced: about 2 months ago
JSON representation
Wrapper for BitMEX.com REST & WebSocket API
- Host: GitHub
- URL: https://github.com/semashkinvg/bitmex.net
- Owner: semashkinvg
- License: mit
- Created: 2018-03-18T11:37:21.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T01:03:07.000Z (almost 3 years ago)
- Last Synced: 2025-08-26T11:42:10.982Z (about 2 months ago)
- Topics: api-wrapper, bitcoin, bitcoin-api, bitmex, bitmex-api, cryptocurrency, csharp, dotnet, exchange, exchange-api, instrument, position, quotes, rest-api, trade, tradeapi, wrapper
- Language: C#
- Homepage:
- Size: 299 KB
- Stars: 51
- Watchers: 12
- Forks: 26
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bitmex.NET [](https://ci.appveyor.com/project/semashkinvg/bitmex-net) [](https://www.nuget.org/packages/Bitmex.NET/) [](https://gitter.im/Bitmex-Net?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Wrapper for BitMEX.com REST API
## Issue reporting
Feel free to report any bugs/issues you may find in the framework. It's all much appreciated!## Quick Start
Install NuGet package `Install-Package Bitmex.NET`
Create default API service:
First approach, creating default instance
```
var bitmexAuthorization = new BitmexAuthorization()
{
BitmexEnvironment = Bitmex.NET.Models.BitmexEnvironment.Test,
Key = "your api key",
Secret = "your api secret"
};
var bitmexApiService = BitmexApiService.CreateDefaultApi(bitmexAuthorization);
```Another, registering in a DI container (e.g. Unity). 
```
Container.RegisterType();
Container.RegisterType();var authorization = new BitmexAuthorization
{
BitmexEnvironment = Bitmex.NET.Models.BitmexEnvironment.Test,
Key = "your api key",
Secret = "your api secret"
};Container.RegisterInstance(authorization);
```
place an order :
```
private async void Sell()
{
var posOrderParams = OrderPOSTRequestParams.CreateSimpleMarket("XBTUSD", Size, OrderSide.Sell);
await _bitmexApiService.Execute(BitmexApiUrls.Order.PostOrder, posOrderParams).ContinueWith(ProcessPostOrderResult);
}
```## Logging
The current lib uses  to provide comprehensive logging for the most popular logging frameworks. Setting Debug logging level in your solution will bring about huge logging output because all the HTTP responses and WebSocket messages will be logged. I would recommend you yo forward the debug level logging from the lib into a separate file, but it's always up to you```
```## Extensibility
I haven't implemented and tested all the existing methods yet so that you might want to call BitMEX APIs that haven't been done so far. To make you be able to call all APIs using the existing service I've tried to make the classes extensible.
So...
To implement your own API method please create your own parameters class (or use existing) deriving it from `QueryStringParams` (for GET requests) or `JsonQueryParams`(for POST/PUT/DELETE requests) and a class for requests (or use existing)```
private class SomeQueryStringParams : QueryStringParams
{
[DisplayName("val")]
public string Value { get; set; }
}private class SomeJsonParams : QueryJsonParams
{
[JsonProperty("symbol")]
public string Symbol { get; set; }
}private class AResult
{
[JsonProperty("value")]
public string Value { get; set; }
}
```
Call it
```
var result = await bitmexApiService.Execute(new ApiActionAttributes("anApiMethod", HttpMethods.POST), new SomeJsonParams(){Symbol = "XBTUSD"});// if the method returns an array of objects
var result = await bitmexApiService.Execute(new ApiActionAttributes>("anApiMethod", HttpMethods.POST), new SomeJsonParams(){Symbol = "XBTUSD"});
```## Docs
Please checkout . During the time I will be adding solutions, best practices, life examples and some other information with peculiarities about Bitmex## Examples
Please see example of simple Buy&Sell application 
### Integration Tests
You will find a live example for all the implemented APIs within integration tests project 
## Other
API was taken from 