CoinTools: a set of command-line tools and Ruby libs for checking cryptocurrency prices on CoinMarketCap etc.

Link: [](

I’ve been building some tools for myself since January to automate some work around crypto trading. One thing I needed was a way to quickly check the price of a given coin right now or in the past (“what was the price of BTC on Kraken last Monday when I made that purchase/sale?”), either manually when I’m updating some spreadsheets, or as a part of some larger script. Previously I’d usually do this manually, opening CoinMarketCap/Bitcoinity/Cryptowatch, finding the right date and reading the value from the chart, but it was pointless work that added up to quite a lot of time, so it seemed like a perfect thing to automate by connecting to these sites’ APIs. (Of course it kind went like this: []( since I probably spent way more time building this than I saved…)

So far I’ve added support for 3 price APIs: CMC, []( and [](, and I’m not really planning to add any more at this point since this covers everything I need: CMC lists every coin possible, []( has past prices for most major coins on major exchanges with pretty good precision, and []( has past prices for more coins but with worse precision.


All 3 can be used in two ways:


1. From the command line:

> cmcap bitcoin
bitcoin @ 2018-07-12 16:52:37 +0200 ==> 6201.51 USD

You can add `-q` to get just the value, if you want to pass it further to other commands:

> cmcap bitcoin -q | sed -e ‘s/./,/’ >> stats.csv

For Cryptowatch and CoinCap you can also check historical prices (the precision usually decreases the further you go in the past, but it should usually be good enough):

> cryptowatch kraken btceur “2017-12-27 9:30”
kraken:btceur @ 2017-12-27 09:00:00 +0100 ==> 13562.4 EUR

CoinMarketCap doesn’t currently have a public API that lets you check prices in the past.


2. If you know Ruby, you can make all the same calls from code, and some more – e.g. for CMC there’s a method to download all coins on the site sorted by rank.

require ‘cointools’

cw =
result = cw.get_price(‘kraken’, ‘btceur’,, 12, 1))
puts result.price

cmc =
cmc.get_all_prices.first(10).each { |c| p [c.symbol, c.usd_price] }


Hopefully someone will find these tools useful 🙂

View Reddit by psionidesView Source

Related Posts

Add Comment