Skip to content

burakoner/BtcTurk.Net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Icon BtcTurk.Net

A .Net wrapper for the BtcTurk API as described on BtcTurk, including all features the API provides using clear and readable objects.

If you think something is broken, something is missing or have any questions, please open an Issue

CryptoExchange.Net

Implementation is build upon the CryptoExchange.Net library, make sure to also check out the documentation on that: docs

My CryptoExchange.Net implementations:


OKEx

Chiliz

BitMax

BtcTurk

Paribu

Thodex

Coinzo

Tatum

JKorf CryptoExchange.Net implementations:


Binance

Bitfinex

Bittrex

CoinEx

Huobi

Kraken

Kucoin

Implementations from third parties:


Bitmex

Exante

HitBTC

Liquid

LiveCoin

Switcheo

Donations

Donations are greatly appreciated and a motivation to keep improving.

BTC: 33WbRKqt7wXARVdAJSu1G1x3QnbyPtZ2bH
ETH: 0x65b02db9b67b73f5f1e983ae10796f91ded57b64

Installation

Nuget version Nuget downloads Available on Nuget.

PM> Install-Package BtcTurk.Net

To get started with BtcTurk.Net first you will need to get the library itself. The easiest way to do this is to install the package into your project using NuGet. Using Visual Studio this can be done in two ways.

Using the package manager

In Visual Studio right click on your solution and select 'Manage NuGet Packages for solution...'. A screen will appear which initially shows the currently installed packages. In the top bit select 'Browse'. This will let you download net package from the NuGet server. In the search box type 'BtcTurk.Net' and hit enter. The BtcTurk.Net package should come up in the results. After selecting the package you can then on the right hand side select in which projects in your solution the package should install. After you've selected all project you wish to install and use BtcTurk.Net in hit 'Install' and the package will be downloaded and added to you projects.

Using the package manager console

In Visual Studio in the top menu select 'Tools' -> 'NuGet Package Manager' -> 'Package Manager Console'. This should open up a command line interface. On top of the interface there is a dropdown menu where you can select the Default Project. This is the project that BtcTurk.Net will be installed in. After selecting the correct project type Install-Package BtcTurk.Net in the command line interface. This should install the latest version of the package in your project.

After doing either of above steps you should now be ready to actually start using BtcTurk.Net.

Getting started

After installing it's time to actually use it. To get started we have to add the BtcTurk.Net namespace: using BtcTurk.Net;.

BtcTurk.Net provides two clients to interact with the BtcTurk API. The BtcTurkClient provides all rest API calls. The BtcTurkSocketClient provides functions to interact with the websocket provided by the BtcTurk API. Both clients are disposable and as such can be used in a usingstatement.

Examples

Public Api Endpoints:

BtcTurkClient apiClient = new BtcTurkClient();
var btc00 = apiClient.GetServerVersion();
var btc01 = apiClient.GetServerTime();
var btc02 = apiClient.GetServerMobileVersion();
var btc03 = apiClient.GetServerExchangeInfo();
var btc04 = apiClient.GetServerPing();
var btc05 = apiClient.GetTicker("BTCTRY");
var btc06 = apiClient.GetTradesV2("BTCTRY");
var btc07 = apiClient.GetPriceGraphHistory("BTCTRY", Net.Objects.BtcTurkPeriod.OneHour);
... etc

Private Api Endpoints:

var apiClient = new BtcTurkClient();
apiClient.SetApiCredentials("XXXXXXXX-API-KEY-XXXXXXXX", "XXXXXXXX-API-SECRET-XXXXXXXX");
var btc11 = apiClient.GetBalances();
var btc12 = apiClient.PlaceOrder("BTCTRY", 1.0m, Net.Objects.BtcTurkOrderSide.Buy, Net.Objects.BtcTurkOrderMethod.Market);
... etc

Websockets

The BtcTurk.Net socket client provides several socket endpoint to which can be subscribed.

Public Socket Endpoints:

var pairs = new List<string> {
    "ATOMTRY","BTCTRY","DASHTRY","EOSTRY","ETHTRY","LINKTRY","LTCTRY","NEOTRY","USDTTRY","XLMTRY","XRPTRY","XTZTRY",
    "ATOMUSDT","BTCUSDT","DASHUSDT","EOSUSDT","ETHUSDT","LINKUSDT","LTCUSDT","NEOUSDT","XLMUSDT","XRPUSDT","XTZUSDT",
    "ATOMBTC","DASHBTC","EOSBTC","ETHBTC","LINKBTC","LTCBTC","NEOBTC","XLMBTC","XRPBTC","XTZBTC"
};

/* BtcTurkSocketClient Object */
var sock = new BtcTurkSocketClient(new BtcTurkSocketClientOptions { LogVerbosity = CryptoExchange.Net.Logging.LogVerbosity.Debug);

/* Public Socket Endpoints: */
var subs = new List<UpdateSubscription>();

// Single Ticker
{
    var subscription = sock.SubscribeToTicker("BTCTRY", (ticker) =>
    {
        if (ticker != null)
        {
            Console.WriteLine($"Channel: {ticker.Channel} Event:{ticker.Event} Type:{ticker.Type} >> " +
            $"B:{ticker.Bid} A:{ticker.Ask} PS:{ticker.PairSymbol} NS:{ticker.NumeratorSymbol} DS:{ticker.DenominatorSymbol} " +
            $"O:{ticker.Open} H:{ticker.High} L:{ticker.Low} LA:{ticker.Close} V:{ticker.Volume} " +
            $"AV:{ticker.AveragePrice} D:{ticker.DailyChange} DP:{ticker.DailyChangePercent} PId:{ticker.PairId} Ord:{ticker.OrderNum} ");
        }
    });
    subs.Add(subscription.Data);
}

// All Tickers
{
    var subscription = sock.SubscribeToTickers((data) =>
    {
        if (data != null)
        {
            foreach (var ticker in data.Items)
            {
                Console.WriteLine($"Channel: {data.Channel} Event:{data.Event} Type:{data.Type} >> " +
                    $"B:{ticker.Bid} A:{ticker.Ask} PS:{ticker.PairSymbol} NS:{ticker.NumeratorSymbol} DS:{ticker.DenominatorSymbol} " +
                    $"O:{ticker.Open} H:{ticker.High} L:{ticker.Low} LA:{ticker.Close} V:{ticker.Volume} " +
                    $"AV:{ticker.AveragePrice} D:{ticker.DailyChange} DP:{ticker.DailyChangePercent} PId:{ticker.PairId} Ord:{ticker.OrderNum} ");
            }
        }
    });
    subs.Add(subscription.Data);
}

// Klines
foreach (var pair in pairs)
{
    var subscription = sock.SubscribeToKlines(pair, Net.Objects.BtcTurkPeriod.OneMinute, (data) =>
    {
        if (data != null)
        {
            Console.WriteLine($"Channel: {data.Channel} Event:{data.Event} Type:{data.Type} >> D:{data.Date} S:{data.Pair} P:{data.Period} O:{data.Open} H:{data.High} L:{data.Low} V:{data.Close} V:{data.Volume}");
        }
    });
    subs.Add(subscription.Data);
}

// Single Trade
{
    var subscription = sock.SubscribeToTrades("BTCTRY", (trades) =>
    {
        if (trades != null)
        {
            foreach (var trade in trades.Items)
            {
                Console.WriteLine($"Channel: {trades.Channel} [List] Event:{trades.Event} Type:{trades.Type} PairSymbol:{trades.PairSymbol} >> " +
                    $"D:{trade.Time} I:{trade.TradeId} A:{trade.Amount} A:{trade.Price} PS:{trade.PairSymbol} S:{trade.S} ");
            }
        }
    }, (trade) =>
    {
        if (trade != null)
        {
            Console.WriteLine($"Channel: {trade.Channel} [Row] Event:{trade.Event} Type:{trade.Type} PairSymbol:{trade.PairSymbol} >> " +
            $"D:{trade.Time} I:{trade.TradeId} A:{trade.Amount} A:{trade.Price} PS:{trade.PairSymbol} S:{trade.S} ");
        }
    });
    subs.Add(subscription.Data);
}

// All Pairs Trades
foreach (var pair in pairs)
{
    var subscription = sock.SubscribeToTrades(pair, (trades) =>
    {
        if (trades != null)
        {
            foreach (var trade in trades.Items)
            {
                Console.WriteLine($"Channel: {trades.Channel} [List] Event:{trades.Event} Type:{trades.Type} PairSymbol:{trades.PairSymbol} >> " +
                    $"D:{trade.Time} I:{trade.TradeId} A:{trade.Amount} A:{trade.Price} PS:{trade.PairSymbol} S:{trade.S} ");
            }
        }
    }, (trade) =>
    {
        if (trade != null)
        {
            Console.WriteLine($"Channel: {trade.Channel} [Row] Event:{trade.Event} Type:{trade.Type} PairSymbol:{trade.PairSymbol} >> " +
                $"D:{trade.Time} I:{trade.TradeId} A:{trade.Amount} A:{trade.Price} PS:{trade.PairSymbol} S:{trade.S} ");
        }
    });
    subs.Add(subscription.Data);
}

// Order Book Full
foreach (var pair in pairs)
{
    var subscription = sock.SubscribeToOrderBookFull(pair, (data) =>
    {
        if (data != null)
        {
            Console.WriteLine($"Channel: {data.Channel} [Full] Event:{data.Event} Type:{data.Type} PairSymbol:{data.PairSymbol} >> ");
            for (var i = 0; i < Math.Min(data.Asks.Count(), 5); i++)
            {
                Console.WriteLine($"Ask {i + 1} -> Price: {data.Asks[i].Price} Amount:{data.Asks[i].Amount}");
            }
            for (var i = 0; i < Math.Min(data.Bids.Count(), 5); i++)
            {
                Console.WriteLine($"Bid {i + 1} -> Price: {data.Bids[i].Price} Amount:{data.Bids[i].Amount}");
            }
        }
    });
    subs.Add(subscription.Data);
}

// Order Book Difference
foreach (var pair in pairs)
{
    var subscription = sock.SubscribeToOrderBookDiff("BTCTRY", (data) =>
    {
        if (data != null)
        {
            Console.WriteLine($"Channel: {data.Channel} [Full] Event:{data.Event} Type:{data.Type} PairSymbol:{data.PairSymbol} >> ");
            for (var i = 0; i < Math.Min(data.Asks.Count(), 5); i++)
            {
                Console.WriteLine($"Ask {i + 1} -> Price: {data.Asks[i].Price} Amount:{data.Asks[i].Amount}");
            }
            for (var i = 0; i < Math.Min(data.Bids.Count(), 5); i++)
            {
                Console.WriteLine($"Bid {i + 1} -> Price: {data.Bids[i].Price} Amount:{data.Bids[i].Amount}");
            }
        }
    }, (data) =>
    {
        if (data != null)
        {
            Console.WriteLine($"Channel: {data.Channel} [Diff] Event:{data.Event} Type:{data.Type} PairSymbol:{data.PairSymbol} >> ");
            for (var i = 0; i < Math.Min(data.Asks.Count(), 5); i++)
            {
                Console.WriteLine($"Ask {i + 1} -> Price: {data.Asks[i].Price} Amount:{data.Asks[i].Amount}");
            }
            for (var i = 0; i < Math.Min(data.Bids.Count(), 5); i++)
            {
                Console.WriteLine($"Bid {i + 1} -> Price: {data.Bids[i].Price} Amount:{data.Bids[i].Amount}");
            }
        }
    });
    subs.Add(subscription.Data);
}

Private Socket Endpoints:

/* Not supported yet because there isnt any guide how to create login token */

Release Notes

  • Version 2.6.2 - 10 Dec 2022

    • Synced with CryptoExchange.Net v5.3.1
    • Fixed CancelOrder issue
  • Version 2.6.0 - 23 Aug 2022

    • Synced with CryptoExchange.Net v5.2.4
  • Version 2.5.0 - 18 Sep 2021

    • Synced with CryptoExchange.Net v4.1.0
  • Version 2.1.0 - 31 Mar 2021

    • Updated dependencies
  • Version 2.0.1 - 01 Feb 2021

    • Updated CryptoExchange.Net to 3.6.0
  • Version 2.0.0 - 17 Jan 2021

    • All methods are virtual now. You can customize methods by overriding.
    • Fixed several minor bugs
  • Version 1.2.8 - 12 Jan 2021

    • Updated CryptoExchange.Net to 3.5.0
  • Version 1.2.6 - 02 Jan 2021

    • Fixed minor bugs
  • Version 1.2.5 - 23 Dec 2020

    • CryptoExchange version updated to 3.4.0
  • Version 1.2.4 - 12 Dec 2020

    • CryptoExchange version updated to 3.3.0
    • Added v1 v2 v3 Swagger documents and Web Socket manual
  • Version 1.2.3 - 08 Nov 2020

    • Fixed duplicate slashes on BaseAddress caused by CryptoExchange
  • Version 1.2.1 - 08 Nov 2020

    • CryptoExchange version updated to 3.1.0
  • Version 1.2.0 - 21 Sep 2020

    • CryptoExchange version updated to 3.0.14
  • Version 1.0.5 - 14 Jun 2020

    • Added Websocket Endpoints
    • Added Api Authendication
  • Version 1.0.0 - 01 Feb 2020

    • First Release

About

Open source .Net API wrapper for the BtcTurk web API and websockets API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages