Last active
October 13, 2017 03:02
-
-
Save ticoombs/0ad8b4588809f22cec41 to your computer and use it in GitHub Desktop.
[Python] Bitcoin price ticker for Btcmarkets.net
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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