Luu Chi Cuong
Luu Chi Cuong

Reputation: 11

How to use Poloniex API with C# for getting real-time price data

I am using C# code for connecting to Poloniex website, a cryptocurrency exchange. I have two keys, the first is API key, the last is created by Poloniex and sent me via email. I used the first key for PublicKey and the last for PrivateKey. PublicKey and PrivateKey on the ApiKeys.cs class. When I executed the program, I got the error

Additional information: The remote server returned an error: (403) Forbidden".

The link for the [PoloniexApi.Net] project(https://github.com/kripod/PoloniexApi.Net)

struct ApiKeys
{
    // WARNING: In order not to expose the changes of this file to git, please
    //          run the following command every time you clone the repository:
    // git update-index --assume-unchanged "PoloniexApi.Net.Demo\ApiKeys.cs"
        internal const string PublicKey = "mypublickey";
    internal const string PrivateKey = "myprivatekey";
}

enter image description here

Upvotes: 1

Views: 3447

Answers (1)

Vitaliy
Vitaliy

Reputation: 11

It is necessary to take the exception block. Example:

try
 {
   var curr = CurrencyPair.Parse(Scurr);
   var trade = await PoloniexClient.Trading.GetTradesAsync(curr);
   dataGridTradeHistory.Rows.Clear();
   foreach (var trd in trade)
   {
    dataGridTradeHistory.Rows.Add(trd.Time, trd.Type, trd.IdOrder.ToString(), 
    trd.PricePerCoin, trd.AmountBase, trd.AmountQuote);
   }
 } 
catch { }

Upvotes: 1

Related Questions