Author

Topic: [Tutorial] Mac Os X + GeekTool = bitcoin monitoring on your desktop! (Read 3274 times)

member
Activity: 60
Merit: 10
EDIT: NVM figured it out
member
Activity: 86
Merit: 10
Script for BTC Guild!



Quote
#!/usr/bin/python

import urllib2
import json

API_KEY = 'YOUR API KEY HERE'

my_json = json.loads(urllib2.urlopen('http://www.btcguild.com/api.php?api_key=' + API_KEY).read())

total_rewards = my_json['user']['total_rewards']
paid_rewards = my_json['user']['paid_rewards']
unpaid_rewards = my_json['user']['unpaid_rewards']
past_24h_rewards = my_json['user']['past_24h_rewards']
pool_speed = my_json['pool']['pool_speed']

print " -- BTC Guild Pool Stats --"
print "Total rewards : %.8f" % total_rewards
print "Paid rewards  : %.8f" % paid_rewards
print "Unpaid rewards: %.8f" % unpaid_rewards
print "24h rewards   : %.8f" % past_24h_rewards
print "Pool speed    : %s" % pool_speed
print "---------------------------"

for worker in my_json['workers']:
  workerhashrate = my_json['workers'][worker]['hash_rate']
  workershares = my_json['workers'][worker]['valid_shares']
  workerstales = my_json['workers'][worker]['stale_shares']
  if(workershares > 0 and workerstales > 0) :
      workerstale_perc = float(workerstales)/float(workershares) * 100
  else:
      workerstale_perc = 0.0
  print "Worker name: %s" % (my_json['workers'][worker]['worker_name'])
  print "Worker Hashrate %.2f  Shares %d  Stales %d Stale %.2f %%" % (workerhashrate,  workershares, workerstales, workerstale_perc)
  print " ----- "
member
Activity: 86
Merit: 10



Download GeekTool from http://projects.tynsoe.org/en/geektool/download.php

Drag and drop shell icon to your desktop:



Go to properties -> command -> …



Enter script and save changes. Also you can change font and color in properties


 



*** Some scripts ***

Show MtGox rates:

Quote
#!/usr/bin/python

import json
import urllib2

def parse(json_data):
    json_data = json.loads(json_data)

    # get to where the days are listed with the data we want.
    high = json_data['data']['high']['display_short']
    low = json_data['data']['low']['display_short']
    avg = json_data['data']['avg']['display_short']

    return high, low, avg

def fetch():
    # url with API code intact.............TTTHHHIIIISSSSSS
    url = 'https://data.mtgox.com/api/2/BTCUSD/money/ticker'

    try:
        # gets the data from the url and reads it like a file
        response = urllib2.urlopen(url).read()
    except urllib2.URLError:
        sys.exit()

    return response

if __name__ == '__main__':
    response = fetch()
    high, low, avg = parse(response)
    print "High: %s" % (high)
    print "Low : %s" % (low)
    print "Avg : %s" % (avg)

Show network difficulty
Quote
#!/usr/bin/python
import urllib2
 
def get_info(url):
    info = urllib2.urlopen(url)
    ats = info.read()
    return(ats)
  
next = int(float(get_info('http://blockexplorer.com/q/estimate/')))
now = int(float(get_info('http://blockexplorer.com/q/getdifficulty')))
perc = 100 - (100 * now / next)

print "Now ", now
print "Next ", next
print "Difference %s (%s%%)" % ((next - now), perc)



Please share your own scripts!

Working with btcguild statistics - completed
Working with slush pool statistics

If you like this tutorial, you can buy some beer for me Grin 1DXuRTFTJXpQBKKmcXjvy6nYRhNGTFJap6
Jump to: