Support for getting token USD value

* utility function for getting current USD value of a crypto token
  from cryptonator API
This commit is contained in:
Teemu Patja 2017-08-04 11:50:51 +03:00
parent 153c3dc7cb
commit f379da4924
No known key found for this signature in database
GPG Key ID: F5B7035E6580FD4C

View File

@ -0,0 +1,14 @@
(ns commiteth.util.crypto-fiat-value
(:require [clj-http.client :as http]
[clojure.data.json :as json]))
(defn get-token-usd-price [token]
(let [url (str "https://api.cryptonator.com/api/ticker/"
token
"-usd")
m (->> (http/get url)
(:body)
(json/read-str))]
(-> (get-in m ["ticker" "price"])
(read-string))))