#! /usr/bin/python2
# mintpal api coin converter
#
import json
import urllib2
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("quantity", help="How many coins to convert", type=int)
parser.add_argument("base", help="Coin to start with", type=str)
args = parser.parse_args()
class MintPal():
def __init__(self):
self.version = 0.1
self.author = "STumbles"
def to_ltc(self):
self.url = "https://api.mintpal.com/v1/market/stats/%s/ltc" % (args.base)
self.data = json.loads(urllib2.urlopen(self.url).read())
self.coin_name = self.data[0]['coin']
self.coin_value = self.data[0]['last_price']
self.user_coin_total_worth = float(self.coin_value) * float(args.quantity)
print "%d %s is worth %s LiteCoins (LTC)" % (args.quantity, self.coin_name, str(self.user_coin_total_worth))
def main():
mp = MintPal()
mp.to_ltc()
if __name__ == "__main__":
main()
http://dpaste.com/12CMH2D this one uses mintpal (my other used cryptonator.) the API's are slightly different and i havent added in any coin_conversion yet. but this current build will allow quick command_line checking of PND -> LTC [doesnt have to be pnd. can be any mintpal/ltc coin(also easily editable for mintpal/btc markets)]
USAGE : python2 mintpal.py quantity coinabbreviation
EXAMPLE : python2 mintpal.py 15000 pnd
RESULT : 15000 PandaCoin (PND) is worth 0.04065 LiteCoins (LTC)
IN THE FUTURE
support for USD
converting to other coins rather than ltc/btc
i had this down easily and simply with the last API. results were not accurate though