C# can't read and interpret web API/JSON


My first question here, probably because I found loads of previous questions & answers here :) I'm just a hobby programmer, I know only the basics, but I just love programming :D I've been cracking my head over the following problem for 2 days now, and I wonder if you guys could help me?

I'm programming a GUI monitor for my bitcoin/altcoin miners (specifically, ccminer for NVIDIA miners), and I want a miner to be able to jump on the most profitable coin if I have set a config for it. The easiest way to get these numbers would be trough the numerous web API's, like <a href="http://www.coinmine.pw/api.php?method=coinprofit" rel="nofollow">this</a> and <a href="http://www.whattomine.com/coins.json" rel="nofollow">this</a>. So you can see, there are numerous API's (would've linked more, but not allowed yet), but none of them seems to work.

This is the code I have so far:

class Api { public static List<Coins> _download_serialized_json_data(string address) { List<Coins> coinList = new List<Coins>(); using (WebClient web = new WebClient()) { string jsonData = web.DownloadString(address); JObject json = JObject.Parse(jsonData); for (int i = 1; i <= 10; i++) { Coins c = new Coins(); c.tag = json["coins"][i]["tag"]; coinList.Add(c); } } return coinList; } } public class Coins { public string tag { get; set; } }

ATM, I'm using the debug mode just to look at what's inside the objects but when I try to use my method at this api (or any other with corresponding elements) but at

c.tag = json["coins"][i]["tag"];

It errors out. I don't know where to find the exact error too, but even when I'm trying JArray.Parse it just doesn't work. Am I making a crucial mistake somewhere?

Many thanks in advance!


Are you trying to do something like this?

Webclient wc = new Webclient(); var json = wc.DownloadString("http://www.whattomine.com/coins.json"); //your 2nd link var coins = JsonConvert.DeserializeObject<Coins>(json); <hr />public class Coins { public Dictionary<string, Coin> coins = null; } public class Coin { public string tag { get; set; } public string algorithm { get; set; } public double block_reward { get; set; } public int block_time { get; set; } public int last_block { get; set; } public double difficulty { get; set; } public double difficulty24 { get; set; } public double nethash { get; set; } public double exchange_rate { get; set; } public string market_cap { get; set; } public double volume { get; set; } public int profitability { get; set; } public int profitability24 { get; set; } }



c.tag = json["coins"][i]["tag"].ToString();


  • Using system commands in Perl instead of built in libraries/functions [duplicate]
  • Prolog list not printing all the elements on console
  • Why I have got an error when try save the game ? Unity C#
  • Uncaught TypeError: this.$store.commit is not a function
  • Opening file from a Fileshare-system with python
  • Updating texture not working
  • edge detection iphone opencv
  • Add key and value to all childs in JSON tree in Firebase
  • How to play Youtube videos using Video.js?
  • extract information from xml file as RDF triples
  • .net console app with hyperlinks?
  • SAP Where-used list Standard programs
  • How can I stub rand in minitest?
  • Converting a Brownfield PHP Webapp to Zend Framework
  • Different occurrences of a specific key in an array of hashes
  • selectInput can't populate duplicate values (using uiOutput and renderUI) in Shiny
  • Read a file in “chunks” using PHP
  • Leaflet z-index
  • auth.provider is not set to 'password' when user signs-in with email and password
  • Cross platform UI spacing/padding
  • How can I extend PHP DOMElement?
  • How to attach a node.js readable stream to a Sendgrid email?
  • Database structure design with variable amounts of fields
  • Reading JSON from a file using C++ REST SDK (Casablanca)
  • Highlight one bar in a series in highcharts?
  • FB SDK and cURL: Unknown SSL protocol error in connection to graph.facebook.com:443
  • Hazelcast - OperationTimeoutException
  • XCode can't find symbols for a specific iOS library/framework project
  • R: gsub and capture
  • RestKit - RKRequestDelegate does not exist
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Is there a mandatory requirement to switch app.yaml?
  • Comma separated Values
  • Revoking OAuth Access Token Results in 404 Not Found
  • How to set the response of a form post action to a iframe source?
  • Change div Background jquery
  • Qt: Run a script BEFORE make
  • reshape alternating columns in less time and using less memory
  • UserPrincipal.Current returns apppool on IIS
  • How to load view controller without button in storyboard?