Skip to content

Instantly share code, notes, and snippets.

@Aareon
Created March 29, 2016 01:12
Show Gist options
  • Select an option

  • Save Aareon/11166bc9a197e81f27e3 to your computer and use it in GitHub Desktop.

Select an option

Save Aareon/11166bc9a197e81f27e3 to your computer and use it in GitHub Desktop.
import urllib2, json, re
from util.parse import parse_json
api_url = "http://corgex.corgicoin.co.uk/api_fetch.php?method="
def api_info():
response = urllib2.urlopen(api_url+"getinfo")
page = response.read()
getinfo = json.loads(page)
if getinfo["status"] == 1:
block_height = str(getinfo["data"]["blocks"])
pow_diff = getinfo["data"]["difficulty"]["proof-of-work"]
pos_diff = getinfo["data"]["difficulty"]["proof-of-stake"]
money_supply = getinfo["data"]["moneysupply"]
connections = str(getinfo["data"]["connections"])
api_info.api_output = ("Coin: {blue}CORG {black}| Height: {blue}"+block_height+
"{black} | POW Diff: {blue}"+pow_diff+"{black} | POS Diff: {blue}"+pos_diff+
"{black} | Money Supply: {blue}"+money_supply+"{black} | Connections: {blue}"+
connections+"{black}.")
return()
else:
api_info.api_output = "A connection to the explorer could not be established."
return()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment