• Documentation
  • Api Reference
Show / Hide Table of Contents
  • Introduction
  • Installation
  • Usage
  • Donation

Example usage

Following is an example structure of a very basic console application.

The EzBtcClient implements IDisposable, so the using statement ensures that Dispose is called even if an exception occurs while you are calling methods on the object.

using EzBtc.Api;
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello ezBtc!");

            using (var client = new EzBtcClient())
            {
                try
                {
                    // Do work here.
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            Console.ReadKey();
        }
    }
}

Get ticker information

var ticker = client.GetTickerAsync("xbtcad").GetAwaiter().GetResult();

Console.WriteLine("Volume = " + ticker.Volume);
Console.WriteLine("Last = " + ticker.Last);
Console.WriteLine("Low = " + ticker.Low);
Console.WriteLine("High = " + ticker.High);

Get order book information

var book = client.GetOrderBookAsync().GetAwaiter().GetResult();

foreach (var entry in book.Bids)
{
    Console.WriteLine("Bid {0} for {1}.", entry.Amount, entry.Rate);
}

foreach (var entry in book.Asks)
{
    Console.WriteLine("Ask {0} for {1}.", entry.Amount, entry.Rate);
}

Get completed trades

var trades = client.GetTransactionsAsync().GetAwaiter().GetResult();

foreach (var trade in trades)
{
    Console.WriteLine("ID = {0}, Type = {1}, Amount = {2}, Rate = {3}", 
        trade.TradeId, trade.Type, trade.Amount, trade.Rate);
}
  • Improve this Doc
Back to top Generated by DocFX