简体   繁体   中英

C# MtGox Value Grabber

Okay guys, here's the deal. I'm a total C# beginner but I've been advised to learn it. I'm desperate to get a working Bitcoin value grabber going - so that I can record the values to a text file. Another thing is that the value must be from MtGox, either their API or their homepage.

I've spent a while dealing with HTTP requests and JSON decoding (grrr...) but I don't see the point in me spending so much time on my learning code when I'm sure there is someone else out there who can just help me to write it.

Does anyone think they might be able to help with this? Just a couple of lines to pull the last Bitcoin value from MtGox.

Any contributions are much appreciated. Will.

EDIT:

var json = WebClient.DownloadString("http://data.mtgox.com/api/2/BTCUSD/money/ticker_fast");

string valueOriginal = Convert.ToString(json);

That is all I needed to write. Wow. Thanks for the help though, Oliver.

This is a Q&A site, so don't expect other's to write your code for you.

You can access their API using any language that supports HTTP calls. Here's a great document to get you started: MtGOX api docs

This is a judgement call, but it sounds like you're new to programming in general. Don't commit yourself to a language. Always use the best tool for the job. I'd suggest using something a bit more "web friendly" for this sort of work. NodeJS would make this much easier for you as it understands the JSON returned from their API nativly, without using all sorts of wrappers and instances of the WebClient class or HttpResponseMessages as you do in .NET. Also consider the purpose of writing the data to a text file. What is going to consume that data? It's possible that you can skip the file and just interact with the down-level consumer directally.

What format needs to be in the data file? If you can save it in JSON, you could do this in C#

using System.Net;
//...
WebClient Client = new WebClient ();
Client.DownloadFile("https://mtgox.com/api/1/BTCUSD/ticker", @"C:\folder\results.json");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM