Skip to content

Instantly share code, notes, and snippets.

@iamvee
Last active June 8, 2020 10:50
Show Gist options
  • Save iamvee/a247508c3fd0c71894a1b16c50782440 to your computer and use it in GitHub Desktop.
Save iamvee/a247508c3fd0c71894a1b16c50782440 to your computer and use it in GitHub Desktop.
BTC and ETH prices
import urllib.request
import json
import pprint
currencies = ["USD","EUR","IRR"]
coins = ["BTC","ETH"]
coins_str = ",".join(coins)
currencies_str = ",".join(currencies)
query = f"fsyms={coins_str}&tsyms={currencies_str}"
url = f"https://min-api.cryptocompare.com/data/pricemulti?{query}"
with urllib.request.urlopen(url) as req:
body = req.read().decode('utf-8')
data = json.loads(body)
pprint.pprint(data)
function prices() {
COINS="BTC,ETH"
CURRENCIES="USD,EUR,IRR"
URL="https://min-api.cryptocompare.com/data/pricemulti?fsyms=${COINS}&tsyms=${CURRENCIES}"
curl $URL -s | jq
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment