Click here to Skip to main content
16,021,115 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello everyone! So after understanding how to get the API to work I managed to set it up so it prints out data to labels flawlessly. Now when I try to do the same thing but with a different API (Almost the same one) it decides not to print it out, feels like I missed some code, is it just me?

The first ticker (Update_BTC_Ticker) works flawlessly, it prints out as it should but the other one (Update_BTC_Trades) does not want to print out, what did I miss out? Maybe someone with a better eye for these types of things would be able to figure it out.


C#
private void Update_BTC_Ticker(object sender, EventArgs e)
{
    var client = new RestClient("https://btc-e.com/api");
    var request = new RestRequest("2/btc_usd/ticker", Method.GET);
    //request.AddHeader("Key", "46G9R9D6-WJ77XOIP-XH9HH5VQ-A3XN3YOZ-8T1R8I8T");
    request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; };

    IRestResponse<BtcUsdTicker> response = client.Execute<BtcUsdTicker>(request);

    sellLabel.Text = Convert.ToString(response.Data.ticker.sell);
    buyLabelTrue.Text = Convert.ToString(response.Data.ticker.buy);


}



private void Update_BTC_Trades(object sender, EventArgs e)
{
    var client = new RestClient("https://btc-e.com/api");
    var request = new RestRequest("2/btc_usd/trades", Method.GET);
    //request.AddHeader("Key", "46G9R9D6-WJ77XOIP-XH9HH5VQ-A3XN3YOZ-8T1R8I8T");
    request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; };

    IRestResponse<BtcTradeTicker> response = client.Execute<BtcTradeTicker>(request);

    textBox1.Text = Convert.ToString(response.Data.tradeTicker.price);


}





public class BtcUsdTicker
{
    public Ticker ticker { get; set; }
}

public class Ticker
{

    public float high { get; set; }
    public float low { get; set; }
    public float avg { get; set; }
    public float vol { get; set; }
    public float vol_cur { get; set; }
    public float last { get; set; }
    public float buy { get; set; }
    public float sell { get; set; }
    public int updated { get; set; }
    public int server_time { get; set; }



}


public class BtcTradeTicker
{
    public tradeTicker tradeTicker { get; set; }
}


public class tradeTicker
{
    public int date { get; set; }
    public double price { get; set; }
    public double amount { get; set; }
    public int tid { get; set; }
    public string price_currency { get; set; }
    public string item { get; set; }
    public string trade_type { get; set; }
}


What I have tried:

I've tried renaming them to differate them which I though was the issue at first now I just feel dizzy and cant seem to locate the issue. The debugger wasnt any help aswell.
Posted
Updated 19-Apr-16 12:56pm

1 solution

My timer blocked the method from being hit.

C#
timer1 = new Timer();
timer1.Tick += new EventHandler(Update_BTC_Ticker);
timer1.Interval = 2000;
timer1.Start();


To

C#
timer1 = new Timer();
timer1.Tick += new EventHandler(Update_BTC_Ticker);
timer1.Tick += new EventHandler(Update_BTC_Trades);
timer1.Interval = 2000;
timer1.Start();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900