Author

Topic: Working with data sources for Bitcoin exchanges (Read 1117 times)

hero member
Activity: 651
Merit: 501
My PGP Key: 92C7689C
December 11, 2012, 06:45:54 PM
#3
btcticker.appspot.com

Interesting...it pulls the information I'd want to use, but it only appears to offer to return the result as text rendered into a PNG.

I've been trying to wrap my head around handling JSON data inside JavaScript.  You'd think this would be easy, but most browsers throw up a roadblock to keep a page from accessing JSON data from other sources.  While this fends off a potential source of XSS attacks, it makes working with data a bit of a pain.  Consider this, based on this demo:

Code:











http://ucommbieber.unl.edu/CORS/cors.php returns a plaintext message when you send it a GET request.  getCORS() is supposed to use cross-origin resource sharing (CORS) to enable fetching data from remote sources.  When you point it at any of the blockchain.info API URLs (even plaintext ones like http://blockchain.info/q/hashrate), though, it fails to pull anything through.  I suspect there's something not implemented server-side.  JSONP fails pretty miserably, too. Is there any method to access JSON data on a remote site from JavaScript in a browser that doesn't rely on you running your own webserver or proxy and that doesn't rely on anything special being set up on the remote server?  Basically, it should be possible to write some HTML and JavaScript into a file and have a browser run it.  I'll be damned if I can figure it out, though.  I've done plenty of JSON manipulation with PHP, so it's not like I'm completely unfamiliar with it.
newbie
Activity: 12
Merit: 0
btcticker.appspot.com
hero member
Activity: 651
Merit: 501
My PGP Key: 92C7689C
I was knocking together a page of links today to use as a homepage on my computers, as part of migrating back to Firefox from Chrome. One thing I thought would be useful in this page would be a readout of the current MtGox ask price.  There are two sources I know of that I could pull in with an XMLHttpRequest:


Ideally, something that returned the "sell" item from the MtGox source as plain text would do what I want. Is such a source already out there, or should I try again to get it myself? I've used PHP to parse JSON, but not JavaScript, and eval() and JSON.Parse() (or whatever it's called) each had their problems working with the data I received from MtGox.

Beyond this somewhat immediate need, perhaps this thread would be useful for gathering info on what other data sources are already available.
Jump to: