def get_from_chain(url_adder):
url = 'https://api.chain.com/v2/bitcoin/%s' % (url_adder)
ok = False
while not ok:
try:
r = requests.get(url, auth=(CHAIN_API_KEY, CHAIN_API_SECRET))
r.raise_for_status()
ok = True
except requests.HTTPError as e:
if r.status_code == 429: # Too many requests
time.sleep(1)
else:
print("Request was to %s" % (url))
raise e
b = json.loads(r.text)
return b
评论列表
文章目录