bettertouchtool-crypto icon indicating copy to clipboard operation
bettertouchtool-crypto copied to clipboard

Request: Is it possible to get an example to fetch from the coinmarketcap API?

Open dylandamsma opened this issue 7 years ago • 4 comments

I.e. if I want to fetch the price from the coinmarketcap API for the ticker Monero, I can use this link to get the price in EUR: https://api.coinmarketcap.com/v1/ticker/monero/?convert=EUR

It returns a JSON body which includes the price. The only thing I don't understand is how to parse that from the JSON using the apple scripting language. Would it be possible to receive an example? I can write the documentation for people how to add any ticker this way using coinmarketcap.

Thank you for making this! Will feature it on Cryptominded.com as Resource of the day next week.

dylandamsma avatar Aug 22 '17 22:08 dylandamsma

@dylandamsma Sorry for the delayed response. The answer it to use "grep" or "sed" or any other unix based tool. BetterTouchTool uses Apple script but can run Unix commands so that's how we do it. When I have time, I can add features to use the coinmarketcap.com API. Probably two weeks from now.

krunkosaurus avatar Sep 05 '17 18:09 krunkosaurus

Would be amazing if it was easy to access any coin from Coinmarketcap.

If I could easily use the URL for Coinmarketcap API and a URL for the coin icon, I could easily customize this for myself with my favorite coins.

zachherbert avatar Sep 14 '17 04:09 zachherbert

@zachherbert This snippet of AppleScript will get any price from https://coinmarketcap.com/ . It depends on having jq installed for grabbing stuff out of the JSON. See https://stedolan.github.io/jq/

set value to do shell script "curl -s https://api.coinmarketcap.com/v1/ticker/bitcoin/ | /usr/local/bin/jq '.[0].price_usd | tonumber'"
return "$" & value

johnthethird avatar Oct 27 '17 18:10 johnthethird

PR created here for CoinMarketCap: https://github.com/krunkosaurus/bettertouchtool-crypto/pull/8

ajc308 avatar Dec 15 '17 02:12 ajc308