Skip to content

Instantly share code, notes, and snippets.

@chris-gong
Created May 15, 2019 00:20
Show Gist options
  • Save chris-gong/b24130f5ea0c6c93e3c24bfb4aca27fd to your computer and use it in GitHub Desktop.
Save chris-gong/b24130f5ea0c6c93e3c24bfb4aca27fd to your computer and use it in GitHub Desktop.
Code for sending requests to the coinbase api and receiving price data as a json response.
import requests
import json
import time
while True :
response = requests.get("https://api.coinbase.com/v2/prices/BTC-USD/spot")
data = response.json()
currency = data["data"]["base"]
price = data["data"]["amount"]
print(f"Currency : {currency} Price: {price}")
time.sleep(5)
@codesperfect
Copy link

Awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment