├── .gitignore ├── CryptopiaApi └── CryptopiaApi │ ├── CryptopiaApi.sln │ ├── CryptopiaApi │ ├── CryptopiaApi.csproj │ ├── CryptopiaPrivateAPI.cs │ ├── CryptopiaPublicAPI.cs │ ├── DataObjects │ │ ├── Private │ │ │ ├── BalanceRequest.cs │ │ │ ├── BalanceResponse.cs │ │ │ ├── CancelTradeRequest.cs │ │ │ ├── CancelTradeResponse.cs │ │ │ ├── DepositAddressRequest.cs │ │ │ ├── DepositAddressResponse.cs │ │ │ ├── OpenOrdersRequest.cs │ │ │ ├── OpenOrdersResponse.cs │ │ │ ├── SubmitTipRequest.cs │ │ │ ├── SubmitTipResponse.cs │ │ │ ├── SubmitTradeRequest.cs │ │ │ ├── SubmitTradeResponse.cs │ │ │ ├── SubmitWithdrawRequest.cs │ │ │ ├── SubmitWithdrawResponse.cs │ │ │ ├── TradeHistoryRequest.cs │ │ │ ├── TradeHistoryResponse.cs │ │ │ ├── TransactionRequest.cs │ │ │ └── TransactionResponse.cs │ │ └── Public │ │ │ ├── CurrenciesResponse.cs │ │ │ ├── MarketHistoryRequest.cs │ │ │ ├── MarketHistoryResponse.cs │ │ │ ├── MarketOrdersRequest.cs │ │ │ ├── MarketOrdersResponse.cs │ │ │ ├── MarketRequest.cs │ │ │ ├── MarketResponse.cs │ │ │ ├── MarketsRequest.cs │ │ │ ├── MarketsResponse.cs │ │ │ └── TradePairsResponse.cs │ ├── Implementation │ │ ├── AuthDelegatingHandler.cs │ │ ├── ICryptopiaApiPrivate.cs │ │ ├── ICryptopiaApiPublic.cs │ │ ├── IRequest.cs │ │ ├── IResponse.cs │ │ ├── PrivateApiCall.cs │ │ └── PublicApiCall.cs │ ├── Models │ │ ├── BalanceResult.cs │ │ ├── CurrencyResult.cs │ │ ├── MarketHistoryResult.cs │ │ ├── MarketOrderResult.cs │ │ ├── MarketOrdersResult.cs │ │ ├── MarketResult.cs │ │ ├── OpenOrderResult.cs │ │ ├── TradeHistoryResult.cs │ │ ├── TradePairResult.cs │ │ └── TransactionResult.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── packages.config │ ├── TestApp │ ├── App.config │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── TestApp.csproj │ └── packages │ ├── Microsoft.AspNet.WebApi.Client.5.2.3 │ ├── Microsoft.AspNet.WebApi.Client.5.2.3.nupkg │ └── lib │ │ ├── net45 │ │ └── System.Net.Http.Formatting.xml │ │ └── portable-wp8+netcore45+net45+wp81+wpa81 │ │ └── System.Net.Http.Formatting.xml │ └── Newtonsoft.Json.6.0.4 │ ├── Newtonsoft.Json.6.0.4.nupkg │ ├── lib │ ├── net20 │ │ └── Newtonsoft.Json.xml │ ├── net35 │ │ └── Newtonsoft.Json.xml │ ├── net40 │ │ └── Newtonsoft.Json.xml │ ├── net45 │ │ └── Newtonsoft.Json.xml │ ├── netcore45 │ │ └── Newtonsoft.Json.xml │ ├── portable-net40+sl5+wp80+win8+wpa81 │ │ └── Newtonsoft.Json.xml │ └── portable-net45+wp80+win8+wpa81 │ │ └── Newtonsoft.Json.xml │ └── tools │ └── install.ps1 └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | obj/ 3 | #ignore thumbnails created by windows 4 | Thumbs.db 5 | #Ignore files build by Visual Studio 6 | *.obj 7 | *.exe 8 | *.pdb 9 | *.user 10 | *.aps 11 | *.pch 12 | *.vspscc 13 | *_i.c 14 | *_p.c 15 | *.ncb 16 | *.suo 17 | *.tlb 18 | *.tlh 19 | *.bak 20 | *.cache 21 | *.ilk 22 | *.log 23 | [Bb]in 24 | [Dd]ebug*/ 25 | *.lib 26 | *.sbr 27 | obj/ 28 | [Rr]elease*/ 29 | _ReSharper*/ 30 | [Tt]est[Rr]esult* 31 | 32 | *.dbmdl 33 | 34 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CryptopiaApi", "CryptopiaApi\CryptopiaApi.csproj", "{30296406-237D-4B4B-8B5A-BDD18F0C2F53}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "TestApp\TestApp.csproj", "{D2B4C405-4A18-4786-A008-B3B27A396916}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {30296406-237D-4B4B-8B5A-BDD18F0C2F53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {30296406-237D-4B4B-8B5A-BDD18F0C2F53}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {30296406-237D-4B4B-8B5A-BDD18F0C2F53}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {30296406-237D-4B4B-8B5A-BDD18F0C2F53}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {D2B4C405-4A18-4786-A008-B3B27A396916}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {D2B4C405-4A18-4786-A008-B3B27A396916}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {D2B4C405-4A18-4786-A008-B3B27A396916}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {D2B4C405-4A18-4786-A008-B3B27A396916}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/CryptopiaApi.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {30296406-237D-4B4B-8B5A-BDD18F0C2F53} 8 | Library 9 | Properties 10 | CryptopiaApi 11 | CryptopiaApi 12 | v4.5 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | false 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | false 34 | 35 | 36 | 37 | ..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll 38 | True 39 | 40 | 41 | 42 | 43 | 44 | 45 | ..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll 46 | True 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 117 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/CryptopiaPrivateAPI.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.DataObjects; 2 | using Cryptopia.API.Implementation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Net.Http; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace Cryptopia.API 11 | { 12 | public class CryptopiaApiPrivate : ICryptopiaApiPrivate 13 | { 14 | private HttpClient _client; 15 | private string _apiBaseAddress; 16 | 17 | public CryptopiaApiPrivate(string key, string secret, string apiBaseAddress = "https://www.cryptopia.co.nz") 18 | { 19 | _apiBaseAddress = apiBaseAddress; 20 | _client = HttpClientFactory.Create(new AuthDelegatingHandler(key, secret)); 21 | } 22 | 23 | #region Api Calls 24 | 25 | public async Task CancelTrade(CancelTradeRequest request) 26 | { 27 | return await GetResult(PrivateApiCall.CancelTrade, request); 28 | } 29 | 30 | public async Task SubmitTrade(SubmitTradeRequest request) 31 | { 32 | return await GetResult(PrivateApiCall.SubmitTrade, request); 33 | } 34 | 35 | public async Task GetBalances(BalanceRequest request) 36 | { 37 | return await GetResult(PrivateApiCall.GetBalance, request); 38 | } 39 | 40 | public async Task GetOpenOrders(OpenOrdersRequest request) 41 | { 42 | return await GetResult(PrivateApiCall.GetOpenOrders, request); 43 | } 44 | 45 | public async Task GetTradeHistory(TradeHistoryRequest request) 46 | { 47 | return await GetResult(PrivateApiCall.GetTradeHistory, request); 48 | } 49 | 50 | public async Task GetTransactions(TransactionRequest request) 51 | { 52 | return await GetResult(PrivateApiCall.GetTransactions, request); 53 | } 54 | 55 | public async Task GetDepositAddress(DepositAddressRequest request) 56 | { 57 | return await GetResult(PrivateApiCall.GetDepositAddress, request); 58 | } 59 | 60 | public async Task SubmitTip(SubmitTipRequest request) 61 | { 62 | return await GetResult(PrivateApiCall.SubmitTip, request); 63 | } 64 | 65 | public async Task SubmitWithdraw(SubmitWithdrawRequest request) 66 | { 67 | return await GetResult(PrivateApiCall.SubmitWithdraw, request); 68 | } 69 | 70 | #endregion 71 | 72 | #region public Members 73 | 74 | public async Task GetResult(PrivateApiCall call, U requestData) 75 | where T : IResponse 76 | where U : IRequest 77 | { 78 | var response = await _client.PostAsJsonAsync(string.Format("{0}/Api/{1}", _apiBaseAddress.TrimEnd('/'), call), requestData); 79 | return await response.Content.ReadAsAsync(); 80 | } 81 | 82 | public void Dispose() 83 | { 84 | if (_client != null) 85 | { 86 | _client.Dispose(); 87 | } 88 | } 89 | 90 | #endregion 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/CryptopiaPublicAPI.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.DataObjects; 2 | using Cryptopia.API.Implementation; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Net.Http; 8 | using System.Runtime.Serialization.Json; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace Cryptopia.API 13 | { 14 | public class CryptopiaApiPublic : ICryptopiaApiPublic 15 | { 16 | private HttpClient _client; 17 | private string _apiBaseAddress; 18 | 19 | public CryptopiaApiPublic(string apiBaseAddress = "https://www.cryptopia.co.nz") 20 | { 21 | _apiBaseAddress = apiBaseAddress; 22 | _client = HttpClientFactory.Create(); 23 | } 24 | 25 | #region Api Calls 26 | 27 | public async Task GetCurrencies() 28 | { 29 | return await GetResult(PublicApiCall.GetCurrencies, null); 30 | } 31 | 32 | public async Task GetTradePairs() 33 | { 34 | return await GetResult(PublicApiCall.GetTradePairs, null); 35 | } 36 | 37 | public async Task GetMarkets(MarketsRequest request) 38 | { 39 | var query = request.Hours.HasValue ? $"/{request.Hours}" : null; 40 | return await GetResult(PublicApiCall.GetMarkets, query); 41 | } 42 | 43 | public async Task GetMarket(MarketRequest request) 44 | { 45 | var query = request.Hours.HasValue ? $"/{request.TradePairId}/{request.Hours}" : $"/{request.TradePairId}"; 46 | return await GetResult(PublicApiCall.GetMarket, query); 47 | } 48 | 49 | public async Task GetMarketHistory(MarketHistoryRequest request) 50 | { 51 | var query = $"/{request.TradePairId}"; 52 | return await GetResult(PublicApiCall.GetMarketHistory, query); 53 | } 54 | 55 | public async Task GetMarketOrders(MarketOrdersRequest request) 56 | { 57 | var query = request.OrderCount.HasValue ? $"/{request.TradePairId}/{request.OrderCount}" : $"/{request.TradePairId}"; 58 | return await GetResult(PublicApiCall.GetMarketOrders, query); 59 | } 60 | 61 | #endregion 62 | 63 | #region public Members 64 | 65 | public async Task GetResult(PublicApiCall call, string requestData) 66 | where T : IResponse, new() 67 | { 68 | var response = await _client.GetStringAsync(string.Format("{0}/Api/{1}{2}", _apiBaseAddress, call, requestData)); 69 | if (string.IsNullOrEmpty(response)) 70 | { 71 | return new T() { Success = false, Error = "No Response." }; 72 | } 73 | return GetObject(response); 74 | } 75 | 76 | private T GetObject(string jsonData) 77 | { 78 | using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(jsonData))) 79 | { 80 | var serializer = new DataContractJsonSerializer(typeof(T)); 81 | return (T)(object)serializer.ReadObject(stream); 82 | } 83 | } 84 | 85 | public void Dispose() 86 | { 87 | if (_client != null) 88 | { 89 | _client.Dispose(); 90 | } 91 | } 92 | 93 | #endregion 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Private/BalanceRequest.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Cryptopia.API.Implementation; 8 | 9 | namespace Cryptopia.API.DataObjects 10 | { 11 | public class BalanceRequest : IRequest 12 | { 13 | /// 14 | /// Initializes a new instance of the class for an all balances request. 15 | /// 16 | public BalanceRequest() 17 | { 18 | } 19 | 20 | /// 21 | /// Initializes a new instance of the class for a specific currency request. 22 | /// 23 | /// The currency symbol of the balance to return. 24 | public BalanceRequest(string currency) 25 | { 26 | Currency = currency; 27 | } 28 | 29 | /// 30 | /// Initializes a new instance of the class for a specific currency request. 31 | /// 32 | /// The Cryptopia currency identifier balance to return. 33 | public BalanceRequest(int currencyId) 34 | { 35 | CurrencyId = currencyId; 36 | } 37 | 38 | /// 39 | /// Gets or sets the currency symbol. 40 | /// 41 | public string Currency { get; set; } 42 | 43 | 44 | /// 45 | /// Gets or sets the Cryptopia currency identifier. 46 | /// 47 | public int? CurrencyId { get; set; } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Private/BalanceResponse.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Cryptopia.API.Implementation; 8 | 9 | namespace Cryptopia.API.DataObjects 10 | { 11 | public class BalanceResponse : IResponse 12 | { 13 | /// 14 | /// Gets or sets a value indicating whether this response was successful. 15 | /// 16 | public bool Success { get; set; } 17 | 18 | /// 19 | /// Gets or sets the error if the response is not successful. 20 | /// 21 | public string Error { get; set; } 22 | 23 | /// 24 | /// Gets or sets the data. 25 | /// 26 | public List Data { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Private/CancelTradeRequest.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Cryptopia.API.Implementation; 8 | 9 | namespace Cryptopia.API.DataObjects 10 | { 11 | public class CancelTradeRequest : IRequest 12 | { 13 | /// 14 | /// Initializes a new instance of the class for an cancel all request. 15 | /// 16 | public CancelTradeRequest() 17 | { 18 | Type = CancelTradeType.All; 19 | } 20 | 21 | /// 22 | /// Initializes a new instance of the class for a specific trade cancel request. 23 | /// 24 | /// The currency symbol of the trade order to cancel. 25 | public CancelTradeRequest(int orderId) 26 | { 27 | OrderId = orderId; 28 | Type = CancelTradeType.Trade; 29 | } 30 | 31 | /// 32 | /// Initializes a new instance of the class for a specific tradepair cancel request. 33 | /// 34 | /// The Cryptopia currency identifier tradepar to cancel. 35 | public CancelTradeRequest(int tradePairId, CancelTradeType type = CancelTradeType.TradePair) 36 | { 37 | TradePairId = tradePairId; 38 | Type = CancelTradeType.TradePair; 39 | } 40 | 41 | /// 42 | /// Gets or sets the trade identifier. 43 | /// 44 | public int? OrderId { get; set; } 45 | 46 | /// 47 | /// Gets or sets the Cryptopia tradepair identifier. 48 | /// 49 | public int? TradePairId { get; set; } 50 | 51 | /// 52 | /// Gets or sets the type of cancel. 53 | /// 54 | public CancelTradeType Type { get; set; } 55 | } 56 | 57 | /// 58 | /// Trade Cancel Type 59 | /// 60 | public enum CancelTradeType 61 | { 62 | /// 63 | /// Single open order cancel 64 | /// 65 | Trade, 66 | 67 | /// 68 | /// Cancel all open orders for tradepair 69 | /// 70 | TradePair, 71 | 72 | /// 73 | /// Cancel All open orders 74 | /// 75 | All 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Private/CancelTradeResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Cryptopia.API.Implementation; 7 | 8 | namespace Cryptopia.API.DataObjects 9 | { 10 | public class CancelTradeResponse : IResponse 11 | { 12 | /// 13 | /// Gets or sets a value indicating whether this response was successful. 14 | /// 15 | public bool Success { get; set; } 16 | 17 | /// 18 | /// Gets or sets the error if the response is not successful. 19 | /// 20 | public string Error { get; set; } 21 | 22 | /// 23 | /// Gets or sets the data. 24 | /// 25 | public List Data { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Private/DepositAddressRequest.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Cryptopia.API.Implementation; 8 | 9 | namespace Cryptopia.API.DataObjects 10 | { 11 | public class DepositAddressRequest : IRequest 12 | { 13 | /// 14 | /// Initializes a new instance of the class for a specific currency request. 15 | /// 16 | /// The currency symbol of the address to return. 17 | public DepositAddressRequest(string currency) 18 | { 19 | Currency = currency; 20 | } 21 | 22 | /// 23 | /// Initializes a new instance of the class for a specific currency request. 24 | /// 25 | /// The Cryptopia currency identifier address to return. 26 | public DepositAddressRequest(int currencyId) 27 | { 28 | CurrencyId = currencyId; 29 | } 30 | 31 | /// 32 | /// Gets or sets the currency symbol. 33 | /// 34 | public string Currency { get; set; } 35 | 36 | 37 | /// 38 | /// Gets or sets the Cryptopia currency identifier. 39 | /// 40 | public int? CurrencyId { get; set; } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Private/DepositAddressResponse.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Cryptopia.API.Implementation; 8 | 9 | namespace Cryptopia.API.DataObjects 10 | { 11 | public class DepositAddressResponse : IResponse 12 | { 13 | /// 14 | /// Gets or sets a value indicating whether this response was successful. 15 | /// 16 | public bool Success { get; set; } 17 | 18 | /// 19 | /// Gets or sets the error if the response is not successful. 20 | /// 21 | public string Error { get; set; } 22 | 23 | /// 24 | /// Gets or sets the data. 25 | /// 26 | public DepositAddress Data { get; set; } 27 | } 28 | 29 | public class DepositAddress 30 | { 31 | /// 32 | /// Gets or sets the currency. 33 | /// 34 | public string Currency { get; set; } 35 | 36 | /// 37 | /// Gets or sets the address. 38 | /// 39 | public string Address { get; set; } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Private/OpenOrdersRequest.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Cryptopia.API.Implementation; 8 | 9 | namespace Cryptopia.API.DataObjects 10 | { 11 | public class OpenOrdersRequest : IRequest 12 | { 13 | /// 14 | /// Initializes a new instance of the class for an all open orders request. 15 | /// 16 | /// The count of records to return. 17 | public OpenOrdersRequest(int? count = null) 18 | { 19 | Count = count; 20 | } 21 | 22 | /// 23 | /// Initializes a new instance of the class for a specific open orders request. 24 | /// 25 | /// The market symbol of the orders to return. 26 | /// The count of records to return. 27 | public OpenOrdersRequest(string market, int? count = null) 28 | { 29 | Count = count; 30 | Market = market; 31 | } 32 | 33 | /// 34 | /// Initializes a new instance of the class for a specific open orders request. 35 | /// 36 | /// The Cryptopia tradepair identifier orders to return. 37 | /// The count of records to return. 38 | public OpenOrdersRequest(int tradePairId, int? count = null) 39 | { 40 | Count = count; 41 | TradePairId = tradePairId; 42 | } 43 | 44 | /// 45 | /// Gets or sets the cryptopia trade pair identifier. 46 | /// 47 | public int? TradePairId { get; set; } 48 | 49 | /// 50 | /// Gets or sets the market identifier. 51 | /// 52 | public string Market { get; set; } 53 | 54 | /// 55 | /// Gets or sets the record count. 56 | /// 57 | public int? Count { get; set; } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Private/OpenOrdersResponse.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.Implementation; 2 | using Cryptopia.API.Models; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Cryptopia.API.DataObjects 10 | { 11 | public class OpenOrdersResponse : IResponse 12 | { 13 | /// 14 | /// Gets or sets a value indicating whether this response was successful. 15 | /// 16 | public bool Success { get; set; } 17 | 18 | /// 19 | /// Gets or sets the error if the response is not successful. 20 | /// 21 | public string Error { get; set; } 22 | 23 | /// 24 | /// Gets or sets the data. 25 | /// 26 | public List Data { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Private/SubmitTipRequest.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Cryptopia.API.Implementation; 8 | 9 | namespace Cryptopia.API.DataObjects 10 | { 11 | 12 | public class SubmitTipRequest : IRequest 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The currency symbol. 18 | /// The minutes the user must have been active in to receive tip. 19 | /// The total amount of coins to spend (amount will be divided equally amongst the active users). 20 | public SubmitTipRequest(string currency, int activeMin, decimal amount) 21 | { 22 | Currency = currency; 23 | ActiveMin = activeMin; 24 | Amount = amount; 25 | } 26 | 27 | /// 28 | /// Initializes a new instance of the class. 29 | /// 30 | /// The currency identifier. 31 | /// The minutes the user must have been active in to receive tip. 32 | /// The total amount of coins to spend (amount will be divided equally amongst the active users). 33 | public SubmitTipRequest(int currencyId, int activeMin, decimal amount) 34 | { 35 | CurrencyId = currencyId; 36 | ActiveMin = activeMin; 37 | Amount = amount; 38 | } 39 | 40 | /// 41 | /// Gets or sets the total amount of coins to spend (amount will be divided equally amongst the active users). 42 | /// 43 | public decimal Amount { get; set; } 44 | 45 | /// 46 | /// Gets or sets the currency. 47 | /// 48 | public string Currency { get; set; } 49 | 50 | /// 51 | /// Gets or sets the currency identifier. 52 | /// 53 | public int? CurrencyId { get; set; } 54 | 55 | /// 56 | /// Gets or sets the minutes the user must have been active in to receive tip. 57 | /// 58 | public int ActiveMin { get; set; } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Private/SubmitTipResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Cryptopia.API.Implementation; 7 | 8 | namespace Cryptopia.API.DataObjects 9 | { 10 | public class SubmitTipResponse : IResponse 11 | { 12 | /// 13 | /// Gets or sets a value indicating whether this response was successful. 14 | /// 15 | public bool Success { get; set; } 16 | 17 | /// 18 | /// Gets or sets the error if the response is not successful. 19 | /// 20 | public string Error { get; set; } 21 | 22 | /// 23 | /// Gets or sets the data. 24 | /// 25 | public string Data { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Private/SubmitTradeRequest.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Cryptopia.API.Implementation; 8 | 9 | namespace Cryptopia.API.DataObjects 10 | { 11 | public class SubmitTradeRequest : IRequest 12 | { 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | /// The Cryptopia market identifier. 17 | /// The type of trade. 18 | /// The amount of coins. 19 | /// The price of the coins. 20 | public SubmitTradeRequest(string market, TradeType type, decimal amount, decimal rate) 21 | { 22 | Market = market; 23 | Type = type; 24 | Amount = amount; 25 | Rate = rate; 26 | } 27 | 28 | /// 29 | /// Initializes a new instance of the class. 30 | /// 31 | /// The Cryptopia tradepair identifier. 32 | /// The type of trade. 33 | /// The amount of coins. 34 | /// The price of the coins. 35 | public SubmitTradeRequest(int tradepairId, TradeType type, decimal amount, decimal rate) 36 | { 37 | TradePairId = tradepairId; 38 | Type = type; 39 | Amount = amount; 40 | Rate = rate; 41 | } 42 | 43 | /// 44 | /// Gets or sets the Cryptopia trade pair identifier. 45 | /// 46 | public int? TradePairId { get; set; } 47 | 48 | /// 49 | /// Gets or sets the market symbol. 50 | /// 51 | public string Market { get; set; } 52 | 53 | /// 54 | /// Gets or sets the trade type. 55 | /// 56 | public TradeType Type { get; set; } 57 | 58 | /// 59 | /// Gets or sets the rate/price. 60 | /// 61 | public decimal Rate { get; set; } 62 | 63 | /// 64 | /// Gets or sets the amount. 65 | /// 66 | public decimal Amount { get; set; } 67 | } 68 | 69 | public enum TradeType 70 | { 71 | Buy, 72 | Sell 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Private/SubmitTradeResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Cryptopia.API.Implementation; 7 | 8 | namespace Cryptopia.API.DataObjects 9 | { 10 | 11 | public class SubmitTradeResponse : IResponse 12 | { 13 | /// 14 | /// Gets or sets a value indicating whether this response was successful. 15 | /// 16 | public bool Success { get; set; } 17 | 18 | /// 19 | /// Gets or sets the error if the response is not successful. 20 | /// 21 | public string Error { get; set; } 22 | 23 | /// 24 | /// Gets or sets the data. 25 | /// 26 | public SubmitTradeData Data { get; set; } 27 | } 28 | 29 | public class SubmitTradeData 30 | { 31 | /// 32 | /// Gets or sets the created order identifier. 33 | /// 34 | public int? OrderId { get; set; } 35 | 36 | /// 37 | /// Gets or sets the list of any filled orders. 38 | /// 39 | public List FilledOrders { get; set; } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Private/SubmitWithdrawRequest.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Cryptopia.API.Implementation; 8 | 9 | namespace Cryptopia.API.DataObjects 10 | { 11 | public class SubmitWithdrawRequest : IRequest 12 | { 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | /// The currency symbol. 17 | /// The total amount of coins to spend (amount will be divided equally amongst the active users). 18 | /// The receiving address (address must belong in you Cryptopia Addressbook).. 19 | public SubmitWithdrawRequest(string currency, decimal amount, string address) 20 | { 21 | Currency = currency; 22 | Address = address; 23 | Amount = amount; 24 | } 25 | 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// The currency identifier. 30 | /// The total amount of coins to spend (amount will be divided equally amongst the active users). 31 | /// The receiving address (address must belong in you Cryptopia Addressbook).. 32 | public SubmitWithdrawRequest(int currencyId, decimal amount, string address) 33 | { 34 | CurrencyId = currencyId; 35 | Address = address; 36 | Amount = amount; 37 | } 38 | 39 | /// 40 | /// Gets or sets the total amount of coins to withdraw. 41 | /// 42 | public decimal Amount { get; set; } 43 | 44 | /// 45 | /// Gets or sets the currency. 46 | /// 47 | public string Currency { get; set; } 48 | 49 | /// 50 | /// Gets or sets the currency identifier. 51 | /// 52 | public int? CurrencyId { get; set; } 53 | 54 | /// 55 | /// Gets or sets the address (address must belong in you Cryptopia Addressbook). 56 | /// 57 | public string Address { get; set; } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Private/SubmitWithdrawResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Cryptopia.API.Implementation; 7 | 8 | namespace Cryptopia.API.DataObjects 9 | { 10 | public class SubmitWithdrawResponse : IResponse 11 | { 12 | /// 13 | /// Gets or sets a value indicating whether this response was successful. 14 | /// 15 | public bool Success { get; set; } 16 | 17 | /// 18 | /// Gets or sets the error if the response is not successful. 19 | /// 20 | public string Error { get; set; } 21 | 22 | /// 23 | /// Gets or sets the data. 24 | /// 25 | public int? Data { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Private/TradeHistoryRequest.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Cryptopia.API.Implementation; 8 | 9 | namespace Cryptopia.API.DataObjects 10 | { 11 | public class TradeHistoryRequest : IRequest 12 | { 13 | /// 14 | /// Initializes a new instance of the class for an all trade history request. 15 | /// 16 | /// The count of records to return. 17 | public TradeHistoryRequest(int? count = null) 18 | { 19 | Count = count; 20 | } 21 | 22 | /// 23 | /// Initializes a new instance of the class for a market specific trade history request. 24 | /// 25 | /// The market symbol of the trade history to return. 26 | /// The count of records to return. 27 | public TradeHistoryRequest(string market, int? count = null) 28 | { 29 | Count = count; 30 | Market = market; 31 | } 32 | 33 | /// 34 | /// Initializes a new instance of the class for a tradepair specific trade history request. 35 | /// 36 | /// The Cryptopia tradepair identifier trade history to return. 37 | /// The count of records to return. 38 | public TradeHistoryRequest(int tradePairId, int? count = null) 39 | { 40 | Count = count; 41 | TradePairId = tradePairId; 42 | } 43 | 44 | /// 45 | /// Gets or sets the cryptopia trade pair identifier. 46 | /// 47 | public int? TradePairId { get; set; } 48 | 49 | /// 50 | /// Gets or sets the market identifier. 51 | /// 52 | public string Market { get; set; } 53 | 54 | /// 55 | /// Gets or sets the record count. 56 | /// 57 | public int? Count { get; set; } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Private/TradeHistoryResponse.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Cryptopia.API.Implementation; 8 | 9 | namespace Cryptopia.API.DataObjects 10 | { 11 | public class TradeHistoryResponse : IResponse 12 | { 13 | /// 14 | /// Gets or sets a value indicating whether this response was successful. 15 | /// 16 | public bool Success { get; set; } 17 | 18 | /// 19 | /// Gets or sets the error if the response is not successful. 20 | /// 21 | public string Error { get; set; } 22 | 23 | /// 24 | /// Gets or sets the data. 25 | /// 26 | public List Data { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Private/TransactionRequest.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Cryptopia.API.Implementation; 8 | 9 | namespace Cryptopia.API.DataObjects 10 | { 11 | public class TransactionRequest : IRequest 12 | { 13 | /// 14 | /// Initializes a new instance of the class fo returning Withdrwa/Deposit transactions. 15 | /// 16 | /// The type of transactions to return. 17 | /// The count of records. 18 | public TransactionRequest(TransactionType type, int? count = null) 19 | { 20 | Type = type; 21 | Count = count; 22 | } 23 | 24 | /// 25 | /// Gets or sets the type of transactions. 26 | /// 27 | public TransactionType Type { get; set; } 28 | 29 | /// 30 | /// Gets or sets the max count of records to return. 31 | /// 32 | public int? Count { get; set; } 33 | } 34 | 35 | public enum TransactionType 36 | { 37 | Deposit, 38 | Withdraw 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Private/TransactionResponse.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Cryptopia.API.Implementation; 8 | 9 | namespace Cryptopia.API.DataObjects 10 | { 11 | public class TransactionResponse : IResponse 12 | { 13 | /// 14 | /// Gets or sets a value indicating whether this response was successful. 15 | /// 16 | public bool Success { get; set; } 17 | 18 | /// 19 | /// Gets or sets the error if the response is not successful. 20 | /// 21 | public string Error { get; set; } 22 | 23 | /// 24 | /// Gets or sets the data. 25 | /// 26 | public List Data { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Public/CurrenciesResponse.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using Cryptopia.API.Implementation; 7 | 8 | namespace Cryptopia.API.DataObjects 9 | { 10 | public class CurrenciesResponse : IResponse 11 | { 12 | public bool Success { get; set; } 13 | public string Error { get; set; } 14 | public List Data { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Public/MarketHistoryRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Cryptopia.API.Implementation; 6 | 7 | namespace Cryptopia.API.DataObjects 8 | { 9 | public class MarketHistoryRequest : IRequest 10 | { 11 | public MarketHistoryRequest(int tradePair) 12 | { 13 | TradePairId = tradePair; 14 | } 15 | public int TradePairId { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Public/MarketHistoryResponse.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using Cryptopia.API.Implementation; 7 | 8 | namespace Cryptopia.API.DataObjects 9 | { 10 | public class MarketHistoryResponse : IResponse 11 | { 12 | public bool Success { get; set; } 13 | public string Error { get; set; } 14 | public List Data { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Public/MarketOrdersRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Cryptopia.API.Implementation; 6 | 7 | namespace Cryptopia.API.DataObjects 8 | { 9 | public class MarketOrdersRequest : IRequest 10 | { 11 | public MarketOrdersRequest(int tradePair, int? orderCount = null) 12 | { 13 | TradePairId = tradePair; 14 | OrderCount = orderCount; 15 | } 16 | public int TradePairId { get; set; } 17 | public int? OrderCount { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Public/MarketOrdersResponse.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using Cryptopia.API.Implementation; 7 | 8 | namespace Cryptopia.API.DataObjects 9 | { 10 | public class MarketOrdersResponse : IResponse 11 | { 12 | public bool Success { get; set; } 13 | public string Error { get; set; } 14 | public MarketOrdersResult Data { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Public/MarketRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Cryptopia.API.Implementation; 6 | 7 | namespace Cryptopia.API.DataObjects 8 | { 9 | public class MarketRequest : IRequest 10 | { 11 | public MarketRequest(int tradePair, int? hours = null) 12 | { 13 | TradePairId = tradePair; 14 | Hours = hours; 15 | } 16 | public int TradePairId { get; set; } 17 | public int? Hours { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Public/MarketResponse.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.Implementation; 2 | using Cryptopia.API.Models; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | namespace Cryptopia.API.DataObjects 9 | { 10 | public class MarketResponse : IResponse 11 | { 12 | public bool Success { get; set; } 13 | public string Error { get; set; } 14 | public MarketResult Data { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Public/MarketsRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Cryptopia.API.Implementation; 6 | 7 | namespace Cryptopia.API.DataObjects 8 | { 9 | public class MarketsRequest : IRequest 10 | { 11 | public MarketsRequest(int? hours = null) 12 | { 13 | Hours = hours; 14 | } 15 | public int? Hours { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Public/MarketsResponse.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.Implementation; 2 | using Cryptopia.API.Models; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | namespace Cryptopia.API.DataObjects 9 | { 10 | public class MarketsResponse : IResponse 11 | { 12 | public bool Success { get; set; } 13 | public string Error { get; set; } 14 | public List Data { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/DataObjects/Public/TradePairsResponse.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Cryptopia.API.Implementation; 8 | 9 | namespace Cryptopia.API.DataObjects 10 | { 11 | public class TradePairsResponse : IResponse 12 | { 13 | public bool Success { get; set; } 14 | public string Error { get; set; } 15 | public List Data { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/Implementation/AuthDelegatingHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net.Http; 5 | using System.Net.Http.Headers; 6 | using System.Security.Cryptography; 7 | using System.Text; 8 | using System.Threading; 9 | using System.Threading.Tasks; 10 | 11 | namespace Cryptopia.API.Implementation 12 | { 13 | public class AuthDelegatingHandler : DelegatingHandler 14 | { 15 | private string _apiKey; 16 | private string _apiSecret; 17 | 18 | public AuthDelegatingHandler(string key, string secret) 19 | { 20 | _apiKey = key; 21 | _apiSecret = secret; 22 | } 23 | 24 | protected async override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) 25 | { 26 | string requestContentBase64String = string.Empty; 27 | string requestUri = System.Web.HttpUtility.UrlEncode(request.RequestUri.AbsoluteUri.ToLower()); 28 | 29 | //Checking if the request contains body, usually will be null wiht HTTP GET 30 | if (request.Content != null) 31 | { 32 | using (var md5 = MD5.Create()) 33 | { 34 | var content = await request.Content.ReadAsByteArrayAsync(); 35 | 36 | //Hashing the request body, any change in request body will result in different hash, we'll incure message integrity 37 | var requestContentHash = md5.ComputeHash(content); 38 | requestContentBase64String = Convert.ToBase64String(requestContentHash); 39 | } 40 | } 41 | 42 | //create random nonce for each request 43 | var nonce = Guid.NewGuid().ToString("N"); 44 | 45 | //Creating the raw signature string 46 | var signatureRawData = string.Concat(_apiKey, "POST", requestUri, nonce, requestContentBase64String); 47 | var secretKeyByteArray = Convert.FromBase64String(_apiSecret); 48 | var signature = Encoding.UTF8.GetBytes(signatureRawData); 49 | using (var hmac = new HMACSHA256(secretKeyByteArray)) 50 | { 51 | var signatureBytes = hmac.ComputeHash(signature); 52 | var requestSignatureBase64String = Convert.ToBase64String(signatureBytes); 53 | 54 | //Setting the values in the Authorization header using custom scheme (amx) 55 | request.Headers.Authorization = new AuthenticationHeaderValue("amx", string.Format("{0}:{1}:{2}", _apiKey, requestSignatureBase64String, nonce)); 56 | } 57 | return await base.SendAsync(request, cancellationToken); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/Implementation/ICryptopiaApiPrivate.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.DataObjects; 2 | using System; 3 | using System.Threading.Tasks; 4 | 5 | namespace Cryptopia.API.Implementation 6 | { 7 | public interface ICryptopiaApiPrivate : IDisposable 8 | { 9 | Task GetResult(PrivateApiCall call, U requestData) 10 | where T : IResponse 11 | where U : IRequest; 12 | Task CancelTrade(CancelTradeRequest request); 13 | Task GetBalances(BalanceRequest request); 14 | Task GetDepositAddress(DepositAddressRequest request); 15 | Task GetOpenOrders(OpenOrdersRequest request); 16 | Task GetTradeHistory(TradeHistoryRequest request); 17 | Task GetTransactions(TransactionRequest request); 18 | Task SubmitTip(SubmitTipRequest request); 19 | Task SubmitTrade(SubmitTradeRequest request); 20 | Task SubmitWithdraw(SubmitWithdrawRequest request); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/Implementation/ICryptopiaApiPublic.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API.DataObjects; 2 | using System; 3 | using System.Threading.Tasks; 4 | 5 | namespace Cryptopia.API.Implementation 6 | { 7 | public interface ICryptopiaApiPublic : IDisposable 8 | { 9 | Task GetResult(PublicApiCall call, string requestData) where T : IResponse, new(); 10 | Task GetCurrencies(); 11 | Task GetMarket(MarketRequest request); 12 | Task GetMarketHistory(MarketHistoryRequest request); 13 | Task GetMarketOrders(MarketOrdersRequest request); 14 | Task GetMarkets(MarketsRequest request); 15 | Task GetTradePairs(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/Implementation/IRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Cryptopia.API.Implementation 8 | { 9 | public interface IRequest { } 10 | } 11 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/Implementation/IResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Cryptopia.API.Implementation 8 | { 9 | public interface IResponse 10 | { 11 | /// 12 | /// Gets or sets a value indicating whether this response was successful. 13 | /// 14 | bool Success { get; set; } 15 | 16 | /// 17 | /// Gets or sets the error if the response is not successful. 18 | /// 19 | string Error { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/Implementation/PrivateApiCall.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Cryptopia.API.Implementation 8 | { 9 | public enum PrivateApiCall 10 | { 11 | CancelTrade, 12 | GetTradeHistory, 13 | GetOpenOrders, 14 | GetBalance, 15 | SubmitTrade, 16 | GetTransactions, 17 | SubmitTip, 18 | GetDepositAddress, 19 | SubmitWithdraw 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/Implementation/PublicApiCall.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Cryptopia.API.Implementation 8 | { 9 | public enum PublicApiCall 10 | { 11 | GetCurrencies, 12 | GetTradePairs, 13 | GetMarkets, 14 | GetMarket, 15 | GetMarketHistory, 16 | GetMarketOrders 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/Models/BalanceResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Cryptopia.API.Models 8 | { 9 | public class BalanceResult 10 | { 11 | public int CurrencyId { get; set; } 12 | public string Symbol { get; set; } 13 | public decimal Total { get; set; } 14 | public decimal Available { get; set; } 15 | public decimal Unconfirmed { get; set; } 16 | public decimal HeldForTrades { get; set; } 17 | public decimal PendingWithdraw { get; set; } 18 | public string Address { get; set; } 19 | public string Status { get; set; } 20 | public string StatusMessage { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/Models/CurrencyResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Cryptopia.API.Models 8 | { 9 | public class CurrencyResult 10 | { 11 | public int Id { get; set; } 12 | public string Name { get; set; } 13 | public string Symbol { get; set; } 14 | public string Algorithm { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/Models/MarketHistoryResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Cryptopia.API.Models 8 | { 9 | public class MarketHistoryResult 10 | { 11 | public int TradePairId { get; set; } 12 | public string Label { get; set; } 13 | public string Type { get; set; } 14 | public decimal Price { get; set; } 15 | public decimal Amount { get; set; } 16 | public decimal Total { get; set; } 17 | public int Timestamp { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/Models/MarketOrderResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Cryptopia.API.Models 8 | { 9 | public class MarketOrderResult 10 | { 11 | public int TradePairId { get; set; } 12 | public string Label { get; set; } 13 | public decimal Price { get; set; } 14 | public decimal Volume { get; set; } 15 | public decimal Total { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/Models/MarketOrdersResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Cryptopia.API.Models 8 | { 9 | public class MarketOrdersResult 10 | { 11 | public List Buy { get; set; } 12 | public List Sell { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/Models/MarketResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Cryptopia.API.Models 8 | { 9 | public class MarketResult 10 | { 11 | public int TradePairId { get; set; } 12 | public string Label { get; set; } 13 | public decimal AskPrice { get; set; } 14 | public decimal BidPrice { get; set; } 15 | public decimal Low { get; set; } 16 | public decimal High { get; set; } 17 | public decimal Volume { get; set; } 18 | public decimal LastPrice { get; set; } 19 | public decimal LastVolume { get; set; } 20 | public decimal BuyVolume { get; set; } 21 | public decimal SellVolume { get; set; } 22 | public decimal Change { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/Models/OpenOrderResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Cryptopia.API.Models 8 | { 9 | public class OpenOrderResult 10 | { 11 | public int OrderId { get; set; } 12 | public int TradePairId { get; set; } 13 | public string Market { get; set; } 14 | public string Type { get; set; } 15 | public decimal Rate { get; set; } 16 | public decimal Amount { get; set; } 17 | public decimal Total { get; set; } 18 | public decimal Remaining { get; set; } 19 | public DateTime TimeStamp { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/Models/TradeHistoryResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Cryptopia.API.Models 8 | { 9 | public class TradeHistoryResult 10 | { 11 | public int TradeId { get; set; } 12 | public int TradePairId { get; set; } 13 | public string Market { get; set; } 14 | public string Type { get; set; } 15 | public decimal Rate { get; set; } 16 | public decimal Amount { get; set; } 17 | public decimal Total { get; set; } 18 | public decimal Fee { get; set; } 19 | public DateTime TimeStamp { get; set; } 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/Models/TradePairResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Cryptopia.API.Models 8 | { 9 | public class TradePairResult 10 | { 11 | public int Id { get; set; } 12 | public string Label { get; set; } 13 | public string Currency { get; set; } 14 | public string Symbol { get; set; } 15 | public string BaseCurrency { get; set; } 16 | public string BaseSymbol { get; set; } 17 | public string Status { get; set; } 18 | public decimal MinimumBaseTrade { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/Models/TransactionResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Cryptopia.API.Models 8 | { 9 | public class TransactionResult 10 | { 11 | public int Id { get; set; } 12 | public string Currency { get; set; } 13 | public string TxId { get; set; } 14 | public string Type { get; set; } 15 | public decimal Amount { get; set; } 16 | public decimal Fee { get; set; } 17 | public string Status { get; set; } 18 | public int Confirmations { get; set; } 19 | public DateTime Timestamp { get; set; } 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("CryptopiaApi")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("CryptopiaApi")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("90592008-6a42-404c-ba25-fe0b635a6832")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/CryptopiaApi/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/TestApp/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/TestApp/Program.cs: -------------------------------------------------------------------------------- 1 | using Cryptopia.API; 2 | using Cryptopia.API.DataObjects; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace TestApp 10 | { 11 | class Program 12 | { 13 | static void Main(string[] args) 14 | { 15 | MainAsync().Wait(); 16 | } 17 | 18 | static async Task MainAsync() 19 | { 20 | using (var client = new CryptopiaApiPublic()) 21 | { 22 | var resultGetMarketOrders = await client.GetMarketOrders(new MarketOrdersRequest(100,10)); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/TestApp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("TestApp")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TestApp")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("d2b4c405-4a18-4786-a008-b3b27a396916")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/TestApp/TestApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {D2B4C405-4A18-4786-A008-B3B27A396916} 8 | Exe 9 | Properties 10 | TestApp 11 | TestApp 12 | v4.5.2 13 | 512 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | {30296406-237d-4b4b-8b5a-bdd18f0c2f53} 55 | CryptopiaApi 56 | 57 | 58 | 59 | 66 | -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/packages/Microsoft.AspNet.WebApi.Client.5.2.3/Microsoft.AspNet.WebApi.Client.5.2.3.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CryptopiaNZ/CryptopiaApi-Csharp/ab4386d69e8be276b824243a0221545c6a238be1/CryptopiaApi/CryptopiaApi/packages/Microsoft.AspNet.WebApi.Client.5.2.3/Microsoft.AspNet.WebApi.Client.5.2.3.nupkg -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/packages/Newtonsoft.Json.6.0.4/Newtonsoft.Json.6.0.4.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CryptopiaNZ/CryptopiaApi-Csharp/ab4386d69e8be276b824243a0221545c6a238be1/CryptopiaApi/CryptopiaApi/packages/Newtonsoft.Json.6.0.4/Newtonsoft.Json.6.0.4.nupkg -------------------------------------------------------------------------------- /CryptopiaApi/CryptopiaApi/packages/Newtonsoft.Json.6.0.4/tools/install.ps1: -------------------------------------------------------------------------------- 1 | param($installPath, $toolsPath, $package, $project) 2 | 3 | # open json.net splash page on package install 4 | # don't open if json.net is installed as a dependency 5 | 6 | try 7 | { 8 | $url = "http://james.newtonking.com/json" 9 | $dte2 = Get-Interface $dte ([EnvDTE80.DTE2]) 10 | 11 | if ($dte2.ActiveWindow.Caption -eq "Package Manager Console") 12 | { 13 | # user is installing from VS NuGet console 14 | # get reference to the window, the console host and the input history 15 | # show webpage if "install-package newtonsoft.json" was last input 16 | 17 | $consoleWindow = $(Get-VSComponentModel).GetService([NuGetConsole.IPowerConsoleWindow]) 18 | 19 | $props = $consoleWindow.GetType().GetProperties([System.Reflection.BindingFlags]::Instance -bor ` 20 | [System.Reflection.BindingFlags]::NonPublic) 21 | 22 | $prop = $props | ? { $_.Name -eq "ActiveHostInfo" } | select -first 1 23 | if ($prop -eq $null) { return } 24 | 25 | $hostInfo = $prop.GetValue($consoleWindow) 26 | if ($hostInfo -eq $null) { return } 27 | 28 | $history = $hostInfo.WpfConsole.InputHistory.History 29 | 30 | $lastCommand = $history | select -last 1 31 | 32 | if ($lastCommand) 33 | { 34 | $lastCommand = $lastCommand.Trim().ToLower() 35 | if ($lastCommand.StartsWith("install-package") -and $lastCommand.Contains("newtonsoft.json")) 36 | { 37 | $dte2.ItemOperations.Navigate($url) | Out-Null 38 | } 39 | } 40 | } 41 | else 42 | { 43 | # user is installing from VS NuGet dialog 44 | # get reference to the window, then smart output console provider 45 | # show webpage if messages in buffered console contains "installing...newtonsoft.json" in last operation 46 | 47 | $instanceField = [NuGet.Dialog.PackageManagerWindow].GetField("CurrentInstance", [System.Reflection.BindingFlags]::Static -bor ` 48 | [System.Reflection.BindingFlags]::NonPublic) 49 | $consoleField = [NuGet.Dialog.PackageManagerWindow].GetField("_smartOutputConsoleProvider", [System.Reflection.BindingFlags]::Instance -bor ` 50 | [System.Reflection.BindingFlags]::NonPublic) 51 | if ($instanceField -eq $null -or $consoleField -eq $null) { return } 52 | 53 | $instance = $instanceField.GetValue($null) 54 | if ($instance -eq $null) { return } 55 | 56 | $consoleProvider = $consoleField.GetValue($instance) 57 | if ($consoleProvider -eq $null) { return } 58 | 59 | $console = $consoleProvider.CreateOutputConsole($false) 60 | 61 | $messagesField = $console.GetType().GetField("_messages", [System.Reflection.BindingFlags]::Instance -bor ` 62 | [System.Reflection.BindingFlags]::NonPublic) 63 | if ($messagesField -eq $null) { return } 64 | 65 | $messages = $messagesField.GetValue($console) 66 | if ($messages -eq $null) { return } 67 | 68 | $operations = $messages -split "==============================" 69 | 70 | $lastOperation = $operations | select -last 1 71 | 72 | if ($lastOperation) 73 | { 74 | $lastOperation = $lastOperation.ToLower() 75 | 76 | $lines = $lastOperation -split "`r`n" 77 | 78 | $installMatch = $lines | ? { $_.StartsWith("------- installing...newtonsoft.json ") } | select -first 1 79 | 80 | if ($installMatch) 81 | { 82 | $dte2.ItemOperations.Navigate($url) | Out-Null 83 | } 84 | } 85 | } 86 | } 87 | catch 88 | { 89 | # stop potential errors from bubbling up 90 | # worst case the splash page won't open 91 | } 92 | 93 | # yolo -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is a C# wapper for the Cryptopia Public and Private API's 2 | 3 | Public Usage: 4 | 5 | using (var api = new CryptopiaApiPublic()) 6 | { 7 | var response = await api.GetCurrencies(); 8 | if (!response.Success) 9 | { 10 | Console.WriteLine(response.Error); 11 | return; 12 | } 13 | 14 | foreach (var currency in response.Data) 15 | { 16 | Console.WriteLine("Currency: {0}", currency.Name); 17 | } 18 | } 19 | 20 | 21 | Private Usage: 22 | 23 | var _apiKey = "your cryptopia api key"; 24 | var _apiSecret = "your cryptopia api secret"; 25 | using (var api = new CryptopiaApiPrivate(_apiKey, _apiSecret)) 26 | { 27 | var response = await api.SubmitTrade(new SubmitTradeRequest("DOT/BTC", TradeType.Buy, 60, 0.00000020M)); 28 | if (!response.Success) 29 | { 30 | Console.WriteLine(response.Error); 31 | return; 32 | } 33 | Console.WriteLine("New Trade Submitted, OrderId: {0}", response.Data.OrderId); 34 | } 35 | --------------------------------------------------------------------------------