KrakenCore icon indicating copy to clipboard operation
KrakenCore copied to clipboard

💱 .NET client for Kraken Bitcoin & cryptocurrency exchange API

KrakenCore

.NET client for Kraken bitcoin exchange API

NuGet Package AppVeyor Build Status Travis Build Status

⚠ This is an alpha version, meaning the API has not been tested on any production application. USE AT OWN RISK! Also, the API does not include the tentative private user funding API as it is subject to change.

🎉 Features

  •  ✖ Cross-platform based on .NET Standard 2.0
  • 🔁 Asynchronous API using async and await
  • 💪 Strongly typed models
  • 🛂 Covered with tests
  • 🔐 Supports two-factor authentication

📦 Getting Started

using KrakenCore;
var client = new KrakenClient(apiKey, privateKey);

var response = await client.GetAccountBalance();
foreach (var currency in response.Result)
    Console.WriteLine($"{currency.Key} : {currency.Value}");

// ZEUR : 1000
// XXBT : 1
// XETH : 3

🔧 Extending Client

The client supports two extensibility points: one right before a request to Kraken is dispatched and one right after a response is received. These points provide additional context specific information (for example, the cost of a particular call) and can be used to implement features such as rate limiting or logging.

Sample extensions implemented in the test suite:

var client = new KrakenClient(ApiKey, PrivateKey)
{
    InterceptRequest = async req =>
    {
        // Log request.
        output.WriteLine(req.HttpRequest.ToString());
        string content = await req.HttpRequest.Content.ReadAsStringAsync();
        if (!string.IsNullOrWhiteSpace(content)) output.WriteLine(content);

        // Wait if we have hit the API rate limit.
        RateLimiter limiter = req.HttpRequest.RequestUri.OriginalString.Contains("/private/")
            ? privateApiRateLimiter
            : publicApiRateLimiter;
        await limiter.WaitAccess(req.ApiCallCost);
    }
};

🙏 Related Work