Provides a Go library for working with the CoinMarketCap Professional API. pro.coinmarketcap.com
go get github.com/g3kk0/go-coinmarketcap
Import package and create client.
import coinmarketcap "github.com/g3kk0/go-coinmarketcap"
key := os.Getenv("COINMARKETCAP_KEY")
cmc := coinmarketcap.NewClient(key)
// by id
params := map[string]string{"id": "1"}
quote, err := cmc.QuotesLatest(params)
if err != nil {
panic(err)
}
// by symbol
params := map[string]string{"symbol": "eth"}
quote, err := cmc.QuotesLatest(params)
if err != nil {
panic(err)
}
// request multiple symbols (works for ids too)
params := map[string]string{"symbol": "bch,eth"}
quotes, err := cmc.QuotesLatest(params)
if err != nil {
panic(err)
}
// specify quote currency (default: usd)
params := map[string]string{"symbol": "bch", "convert": "gbp"}
quote, err := cmc.QuotesLatest(params)
if err != nil {
panic(err)
}