coinmon: In case you don’t want to install 61 packages [1] :)
Posted by jpluimers on 2017/12/04
via: [WayBack] Hacker News – coinmon: In case you don’t want to install 61 packages [1] :) and [WayBack] The curl + jq based approach to check Bitcoin prices looks a bit more attractive than using a node.js package with 61 dependencies, doesn’t it? Source:… – ThisIsWhyICode – Google+
- GitHub repository: bichenkk/coinmon
- Visualization of npm dependencies:
Function to call curl from bash:
$ coinmon() { > curl "https://api.coinmarketcap.com/v1/ticker/?convert=$1" | jq ".[0] .price_$1" > } $ coinmon eur "6988.4723188"
Or in Python (from the same HackerNew thread): [Archive.is] https://www.pastery.net/jnscrh/
#!/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)
–jeroe






Leave a comment