Author

Topic: Simple php script to get data from mtgox. (Read 1869 times)

newbie
Activity: 14
Merit: 0
July 14, 2011, 09:02:34 PM
#7
Very well done!
member
Activity: 62
Merit: 10
Quote
(Don't include this on a highly visited page since it uses alot of resources (because mtgox's gettrades.php is a huge file)

Can be done by using a messaging queue (activeMQ) similar to getting data from the twitter firehose. Setup a background process to cache the file every few minutes.  If not, lke OP says, you best have at least 1-2GB memory and plenty of CPU cycles to handle processing multiple page loads. 

Nice job alkhdaniel  Smiley
hero member
Activity: 658
Merit: 536
Z-pay.io
Thank You guys!
member
Activity: 114
Merit: 10
Quote
alkhdaniel, great! I was looking for something like this.
But I can't download it from solidfiles. Sad Could you re-upload them plz?
http://www.multiupload.com/H87JSOELJW (contains both ticker & trade)
I think this is the exact same script (just looked through it fast before rarring/uploading), might have changed some small detail but doubt it.
If your server accepts JSON and you have some experience in coding you should go with the bitcoinusa.com-code since it's a little bit cleaner than mine though, also mine might not always work (it doesn't send HTTP_USER_AGENT to the server and it seems like mtgox needs this sometimes, atleast there was some problems with the script after the hack a half month ago but i believe it works flawlessly now again). Might fix this little problem if there was some more interest in it though.

~Daniel.
member
Activity: 98
Merit: 10
I could have used this a week ago.
newbie
Activity: 30
Merit: 0
Thanks,

I like.
member
Activity: 114
Merit: 10
Two simple scripts to display some statistics from mtgox, not much more to say really.
These scripts will work without the json extension installed, you only need php to be able to use this.

Mtgoxtrade
Desctiption: Fetches https://mtgox.com/code/data/getTrades.php and convert some data into variables for easier usage. (Don't include this on a highly visited page since it uses alot of resources (because mtgox's gettrades.php is a huge file)
Example page
Download
Usage:
Include mtgoxtrade.class to your php file and use the following variables:
$price(x) Get the price of the x'th last transaction (x=0 will get the latest transaction, x=99 will get the 100th last transaction)
$avgprice(x) Gets the average price of the last x transaction (x=99 will give you the avg of last 100 transactions)
$high Gets you the "high" of how many transactions you specified to read (changed with the $chunk variable inside mtgoxtrade.class)
$low Same as $high but for lowest transaction

There's also some variables that you can change in the .class file, just read the commented lines to see what they do.


Mtgoxtick
Description: Fetches https://mtgox.com/code/data/ticker.php and convert some data into variables for easier usage. Use this instead of Mtgoxtrade if what you're looking for is provided by this script since it uses alot less resources.
Example page
Download
Usage:
Include mtgoxtick.class to your php file and use the following variables:
$high Gets the "high" from mtgox (in usd) (last 24hrs i believe? not sure).
$low Gets the "low" from mtgox (in usd).
$vol Gets the volume of money in the market right now (in btc)
$buy Gets the highest buy price (in usd).
$sell Gets the loewst sell price (in usd)
$last Gets the price of the last bitcoin sold (in usd)

If you like this or use this, please donate to 1Awyxgawq52mkYmiAQ9v4sLPXxStVsSGy8 (even a bitcent would be nice)
Jump to: