#!/usr/bin/env python3 # Created by Mustafa Al-Bassam import json import saxo @saxo.pipe def cap(arg): if not arg: return "Example: .cap BTC" api = "http://coinmarketcap.northpole.ro/api/%s.json" page = saxo.request(api % arg.lower()) try: data = json.loads(page["text"]) except ValueError: return "No data available on that alleged cryptocurrency" result = [data["name"] + ".", "Price: $" + data["price"] + ".", "Market cap: $" + data["marketCap"] + ".", "Current supply: " + data["totalSupply"] + ".", "Volume (24h): $" + data["volume24"] + ".", "Change (24h): " + data["change24"].replace(" ", "") + "."] return " ".join(result)