Skip to content

Instantly share code, notes, and snippets.

@ticoombs
Last active October 13, 2017 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ticoombs/0ad8b4588809f22cec41 to your computer and use it in GitHub Desktop.
Save ticoombs/0ad8b4588809f22cec41 to your computer and use it in GitHub Desktop.
[Python] Bitcoin price ticker for Btcmarkets.net
#!/usr/bin/env python3
import requests
import time
import json
uri = "/market/BTC/AUD/tick"
domain = "https://api.btcmarkets.net"
url = domain + uri
r = requests.get(url, verify=True)
aud = float(s.json()["results"]["AUD_USD"]["val"])
ask = int(r.json()["bestAsk"])
bid = int(r.json()["bestBid"])
last = int(r.json()["lastPrice"])
tstamp = r.json()["timestamp"]
ltime = time.ctime(tstamp)
utime = time.asctime(time.gmtime(tstamp))
def hipchatmsg(data):
hurl = 'https://api.hipchat.com/v2/room/YourRoomNameHere/notification'
hheaders = {'Content-Type': 'application/json', 'Authorization': 'Bearer YourOwnAPIKEYHere'}
hdata = {'color':'green', 'notify':'false', 'message':data,'message_format':'text'}
r2 = requests.post(hurl, data=json.dumps(hdata), headers=hheaders)
if (last) and (aud):
hipchatmsg("Current AUD Price: %s - AUD to USD: %s " % (last, aud))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment