Bitcoin Forum
April 24, 2024, 05:42:37 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Simple php script to get data from mtgox.  (Read 1840 times)
alkhdaniel (OP)
Member
**
Offline Offline

Activity: 114
Merit: 10


View Profile
June 15, 2011, 02:34:37 PM
Last edit: June 28, 2011, 08:16:33 PM by alkhdaniel
 #1

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)
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713980557
Hero Member
*
Offline Offline

Posts: 1713980557

View Profile Personal Message (Offline)

Ignore
1713980557
Reply with quote  #2

1713980557
Report to moderator
1713980557
Hero Member
*
Offline Offline

Posts: 1713980557

View Profile Personal Message (Offline)

Ignore
1713980557
Reply with quote  #2

1713980557
Report to moderator
1713980557
Hero Member
*
Offline Offline

Posts: 1713980557

View Profile Personal Message (Offline)

Ignore
1713980557
Reply with quote  #2

1713980557
Report to moderator
ukbitco.in
Newbie
*
Offline Offline

Activity: 30
Merit: 0


View Profile
June 15, 2011, 03:41:06 PM
 #2

Thanks,

I like.
charliesheen
Member
**
Offline Offline

Activity: 98
Merit: 10


View Profile WWW
June 16, 2011, 04:52:04 AM
 #3

I could have used this a week ago.

alkhdaniel (OP)
Member
**
Offline Offline

Activity: 114
Merit: 10


View Profile
July 14, 2011, 03:38:22 PM
 #4

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.
AlexNeto
Hero Member
*****
Offline Offline

Activity: 658
Merit: 536


Z-pay.io


View Profile WWW
July 14, 2011, 11:54:46 PM
 #5

Thank You guys!

🔥Z-pay.io🔥 - Anonymous bitcoin cheques. FREE mixing.

☝️             ☝️                 ☝️
brandon@sourcewerks
Member
**
Offline Offline

Activity: 62
Merit: 10



View Profile
July 15, 2011, 01:40:04 AM
 #6

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
Leon
Newbie
*
Offline Offline

Activity: 14
Merit: 0



View Profile
July 15, 2011, 02:02:34 AM
 #7

Very well done!
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!