Bitcoin Forum
December 10, 2016, 03:04:46 PM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Simple php script to get data from mtgox.  (Read 1644 times)
alkhdaniel
Member
**
Offline Offline

Activity: 114


View Profile
June 15, 2011, 02:34:37 PM
 #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)
1481382286
Hero Member
*
Offline Offline

Posts: 1481382286

View Profile Personal Message (Offline)

Ignore
1481382286
Reply with quote  #2

1481382286
Report to moderator
1481382286
Hero Member
*
Offline Offline

Posts: 1481382286

View Profile Personal Message (Offline)

Ignore
1481382286
Reply with quote  #2

1481382286
Report to moderator
1481382286
Hero Member
*
Offline Offline

Posts: 1481382286

View Profile Personal Message (Offline)

Ignore
1481382286
Reply with quote  #2

1481382286
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1481382286
Hero Member
*
Offline Offline

Posts: 1481382286

View Profile Personal Message (Offline)

Ignore
1481382286
Reply with quote  #2

1481382286
Report to moderator
1481382286
Hero Member
*
Offline Offline

Posts: 1481382286

View Profile Personal Message (Offline)

Ignore
1481382286
Reply with quote  #2

1481382286
Report to moderator
ukbitco.in
Jr. Member
*
Offline Offline

Activity: 30


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

Thanks,

I like.
charliesheen
Member
**
Offline Offline

Activity: 98


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

I could have used this a week ago.

AlexNeto
Hero Member
*****
Offline Offline

Activity: 572



View Profile
July 14, 2011, 02:35:37 AM
 #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?

Gold is old people's Bitcoin. (c)
alkhdaniel
Member
**
Offline Offline

Activity: 114


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

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: 572



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

Thank You guys!

Gold is old people's Bitcoin. (c)
brandon@sourcewerks
Member
**
Offline Offline

Activity: 62



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

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



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

Very well done!

Opening a webhost soon. Free for the first 5 orders!
http://img593.imageshack.us/img593/7034/iluvbitcoin.png
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!