private void apiButton_Click(object sender, EventArgs e) { var client = new HttpClient(); // var url = "https://api.coinmarketcap.com/v2/ticker/?limit=10"; // old api without authorization var url = "https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?limit=1000"; client.DefaultRequestHeaders.Add("X-CMC_PRO_API_KEY", "f742b5ad-230c-4dfe-b1dc-7fbe4ec51be4"); string response = client.GetStringAsync(url).Result; //Console.Write(response); GetAPI getapi = new GetAPI(); int j = 0; progrssBarlabel.Text = j + "%"; apiProgressBar.Increment(-100); // apiProgressBar.Invoke(new Action(delegate () // { // apiProgressBar.Increment(-100); // })); for (int i = 0; i < 1000; i++) { getapi.cryptoGetData(i, response); apiProgressBar.Increment(1); // MessageBox.Show(i.ToString()); j = i + 1; if (j <= 100) { progrssBarlabel.Text = j + "%"; } } MessageBox.Show("Updated"); }
private void apiButtonAuto() { var client = new HttpClient(); var url = "https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?limit=100"; client.DefaultRequestHeaders.Add("X-CMC_PRO_API_KEY", "f742b5ad-230c-4dfe-b1dc-7fbe4ec51be4"); try { string response = client.GetStringAsync(url).Result; GetAPI getapi = new GetAPI(); for (int i = 0; i < 100; i++) { getapi.cryptoGetData(i, response); } } catch (Exception e) { Console.WriteLine(e); } }