All Projects → binance → binance-connector-dotnet

binance / binance-connector-dotnet

Licence: MIT license
Lightweight connector for integration with Binance API

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to binance-connector-dotnet

binance-spot-order-notification-heoku
[binance order trade fill notification] Telegram Notification when Binance order created, cancelled or filled. Ready to Deploy on Heroku
Stars: ✭ 30 (-61.04%)
Mutual labels:  binance, binance-api
binance-downloader
Python tool to download Binance Candlestick (k-line) data from REST API
Stars: ✭ 44 (-42.86%)
Mutual labels:  binance, binance-api
binance-rs-async
Async client for the Binance APIs
Stars: ✭ 74 (-3.9%)
Mutual labels:  binance, binance-api
howtrader
Howtrader is a crypto currency quant framework, you can easily develop, backtest and run your own strategy in real market. It also supports tradingview or other 3rd party signals, just simply send a post request and it will help trade automatically. Now it only support binance spot, futures and inverse futures exchange. It will support okex, ftx…
Stars: ✭ 294 (+281.82%)
Mutual labels:  binance, binance-api
multi pairs martingle bot
A muti pairs martingle trading bot for Binance exchange.
Stars: ✭ 55 (-28.57%)
Mutual labels:  binance, binance-api
hands-on-elixir-and-otp-cryptocurrency-trading-bot
Source code to generate the "Hands-on Elixir & OTP: Cryptocurrency trading bot" book
Stars: ✭ 210 (+172.73%)
Mutual labels:  binance, binance-api
Bybit-Auto-Trading-Bot-Ordes-placed-via-TradingView-Webhook
Python based Trading Bot that uses TradingView.com webhook JSON alerts to place orders(buy/sell/close/manage positions/TP/SL/TS etc.) on Bybit.com. Hire me directly here https://www.freelancer.com/u/Beannsofts for any assistance
Stars: ✭ 235 (+205.19%)
Mutual labels:  binance, binance-api
hedgehog
Source code for the "Hands-on Elixir & OTP: Cryptocurrency Trading Bot" course
Stars: ✭ 70 (-9.09%)
Mutual labels:  binance, binance-api
unicorn-binance-suite
The UNICORN Binance Suite is a Python Meta Package of unicorn-fy, unicorn-binance-local-depth-cache, unicorn-binance-rest-api, unicorn-binance-trailing-stop-loss and unicorn-binance-websocket-api.
Stars: ✭ 35 (-54.55%)
Mutual labels:  binance, binance-api
binance-client-websocket
🛠️ C# client for Binance websocket API
Stars: ✭ 41 (-46.75%)
Mutual labels:  binance, binance-api
java-binance-api
Java Binance API Client
Stars: ✭ 72 (-6.49%)
Mutual labels:  binance, binance-api
binapi
Binance API C++ implementation
Stars: ✭ 129 (+67.53%)
Mutual labels:  binance, binance-api
oec-ng
OEC 现货交易助手(前端)
Stars: ✭ 14 (-81.82%)
Mutual labels:  spot, binance
binancer
An R client to the Public Rest API for Binance.
Stars: ✭ 51 (-33.77%)
Mutual labels:  binance, binance-api
Crypto Signal
Github.com/CryptoSignal - #1 Quant Trading & Technical Analysis Bot - 3,100+ stars, 900+ forks
Stars: ✭ 3,690 (+4692.21%)
Mutual labels:  binance, binance-api
Benzaiboten-spot-trading-bot
A trading bot easy to use to be linked to your favorite exchange to automatize the trading on cryptocurrencies
Stars: ✭ 20 (-74.03%)
Mutual labels:  spot, binance
BitView
A crypto portfolio written in Flutter. It supports Binance, Bittrex, HitBTC, Coinbase, Coinbase Pro and Mercatox
Stars: ✭ 50 (-35.06%)
Mutual labels:  binance, binance-api
cryptodiversify
Automatically check your portfolio on the Binance exchange and advice you on rebalancing your portfolio into the top 20 cryptocurrencies by market capitalization
Stars: ✭ 43 (-44.16%)
Mutual labels:  binance, binance-api
Twitter Activated Crypto Trading Bot
Buys crypto through keyword detection in new tweets. Executes buy in 1 second and holds for a given time (e.g. Elon tweets 'doge', buys Dogecoin and sells after 5 minutes). Tested on Kraken and Binance exchanges
Stars: ✭ 92 (+19.48%)
Mutual labels:  binance, binance-api
binance-technical-algorithm
Technical trading algorithm for Binance
Stars: ✭ 44 (-42.86%)
Mutual labels:  binance, binance-api

Binance Public API Connector DotNET

[Nuget] License: MIT

This is a lightweight library that works as a connector to Binance public API

  • Supported APIs:
    • /api/*
    • /sapi/*
    • Spot Websocket Market Stream
    • Spot User Data Stream
  • Test cases and examples
  • Customizable base URL, request timeout and HTTP proxy
  • Response Metadata

Installation

dotnet add package Binance.Spot

RESTful APIs

Usage example

using System;
using System.Threading.Tasks;
using Binance.Spot;

class Program
{
    static async Task Main(string[] args)
    {
        Wallet wallet = new Wallet();

        string status = await wallet.SystemStatus();

        Console.WriteLine(status);
    }
}

Please find more examples folder to check for more endpoints.

Websocket

using System;
using System.Threading;
using System.Threading.Tasks;
using Binance.Spot;

class Program
{
    static async Task Main(string[] args)
    {
        var websocket = new MarketDataWebSocket("btcusdt@aggTrade");

        websocket.OnMessageReceived(
            (data) =>
        {
            Console.WriteLine(data);

            return Task.CompletedTask;
        }, CancellationToken.None);

        await websocket.ConnectAsync(CancellationToken.None);
    }
}

More websocket examples are available in the Examples folder

Heartbeat

Once connected, the websocket server sends a ping frame every 3 minutes and requires a response pong frame back within a 10 minutes period. This package handles the pong responses automatically.

Testnet

While /sapi/* endpoints don't have testnet environment yet, /api/* endpoints can be tested in Spot Testnet.

using Binance.Spot;

Wallet wallet = new Wallet(baseUrl: "https://testnet.binance.vision");

Base URL

If baseUrl is not provided, it defaults to https://api.binance.com.

It's recommended to pass in the baseUrl parameter, even in production as Binance provides alternative URLs in case of performance issues:

  • https://api1.binance.com
  • https://api2.binance.com
  • https://api3.binance.com

RecvWindow parameter

Additional parameter recvWindow is available for endpoints requiring signature.

It defaults to 5000 (milliseconds) and can be any value lower than 60000(milliseconds). Anything beyond the limit will result in an error response from Binance server.

using Binance.Spot;

Wallet wallet = new Wallet();

await wallet.AccountStatus(recvWindow=4000)

Timeout

The default timeout is 100,000 milliseconds (100 seconds).

Usage Example

using System;
using System.Net.Http;
using Binance.Spot;

HttpClient httpClient = new HttpClient() { 
    Timeout = TimeSpan.FromSeconds(10)
}

Wallet wallet = new Wallet(httpClient: httpClient);

Proxy

Usage Example

using System;
using System.Net;
using System.Net.Http;
using Binance.Spot;

WebProxy proxy = new WebProxy(new Uri("http://1.2.3.4:8080"));
HttpClientHandler proxyHandler = new HttpClientHandler { Proxy = proxy };
HttpClient httpClient = new HttpClient(handler: proxyHandler);

Wallet wallet = new Wallet(httpClient: httpClient);

Exceptions

There are 2 types of exceptions returned from the library:

  • Binance.Common.BinanceClientException
    • This is thrown when server returns 4XX, it's an issue from client side.
    • Properties:
      • Code - Server's error code, e.g. -1102
      • Message - Server's error message, e.g. Unknown order sent.
  • Binance.Common.BinanceServerException
    • This is thrown when server returns 5XX, it's an issue from server side.

Both exceptions inherit Binance.Common.BinanceHttpException along with the following properties:

  • StatusCode - Response http status code, e.g. 401
  • Headers - Dictionary with response headers

Logging

This library implements the .NET logging API that works with a variety of built-in and third-party logging providers.

For more information on how to configure logging in .NET, visit Microsoft's logging article

Usage Example

using System;
using System.Net;
using System.Net.Http;
using Binance.Spot;

public async Task LoggingExample(ILogger logger) {
    BinanceLoggingHandler loggingHandler = new BinanceLoggingHandler(logger: logger);
    HttpClient httpClient = new HttpClient(handler: loggingHandler);

    Wallet wallet = new Wallet(httpClient: httpClient);

    await wallet.SystemStatus();
}

Sample Output

Method: GET, RequestUri: 'https://www.binance.com/?timestamp=1631525776809&signature=f07558c98cb82bcb3556a6a21b8a8a2582bae93d0bb9604a0df72cae8c1c6642', Version: 1.1, Content: <null>, Headers: { }
StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: <null>, Headers: {}
{"status": 0,"msg": "normal"}

Test Cases

dotnet test

Limitations

Futures and Vanilla Options APIs are not supported:

  • /fapi/*
  • /dapi/*
  • /vapi/*
  • Associated Websocket Market and User Data Streams

Contributing

Contributions are welcome.

If you've found a bug within this project, please open an issue to discuss what you would like to change.

If it's an issue with the API, please open a topic at Binance Developer Community

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].