Pastery

cryptoticker +

#!/usr/bin/env python3

from urllib.request import urlopen
from decimal import Decimal
import json


def print_coin(coin):
    print("{} ticker:".format(coin["name"]))
    print("Price: {:,} EUR".format(Decimal(coin["price_eur"])))
    print("Market cap: {:,} EUR".format(Decimal(coin["market_cap_eur"])))
    print()


r = urlopen("https://api.coinmarketcap.com/v1/ticker/?convert=eur")
coins = json.loads(r.read().decode("utf8"))

for coin in coins:
    if coin["id"] in ("bitcoin", "ethereum", "ripple", "monero"):
        print_coin(coin)
New paste