Coinmarketcap (CMC) Pro API Client written in Golang
go get -u github.com/hexoul/go-coinmarketcap
- As library, start from
coinmarketcap.GetInstanceWithKey('YOUR_API_KEY')
- As program, start from
coinmarketcap.GetInstance()
after executinggo run -cmcApikey=[YOUR_API_KEY]
package main
import (
"fmt"
cmc "github.com/hexoul/go-coinmarketcap"
"github.com/hexoul/go-coinmarketcap/types"
)
func init() {
cmc.GetInstanceWithKey("YOUR_API_KEY")
}
func main() {
if crypto, err := cmc.GetInstance().CryptoInfo(&types.Options{
Symbol: "BTC",
}); err == nil {
fmt.Println(crypto.CryptoInfo["BTC"].Name)
}
client := cmc.GetInstance()
if exchange, err := client.ExchangeInfo(&types.Options{
Slug: "binance",
}); err == nil {
fmt.Println(exchange.ExchangeInfo["binance"].Name)
}
}
Type | Endpoint | Done |
---|---|---|
Cryptocurrency | /v1/cryptocurrency/info | ✔ |
Cryptocurrency | /v1/cryptocurrency/map | ✔ |
Cryptocurrency | /v1/cryptocurrency/listings/latest | ✔ |
Cryptocurrency | /v1/cryptocurrency/listings/historical | - |
Cryptocurrency | /v1/cryptocurrency/market-pairs/latest | ✔ |
Cryptocurrency | /v1/cryptocurrency/ohlcv/latest | ✔ |
Cryptocurrency | /v1/cryptocurrency/ohlcv/historical | ✔ |
Cryptocurrency | /v1/cryptocurrency/quotes/latest | ✔ |
Cryptocurrency | /v1/cryptocurrency/quotes/historical | - |
Exchange | /v1/exchange/info | ✔ |
Exchange | /v1/exchange/map | ✔ |
Exchange | /v1/exchange/listings/latest | ✔ |
Exchange | /v1/exchange/listings/historical | - |
Exchange | /v1/exchange/market-pairs/latest | ✔ |
Exchange | /v1/exchange/quotes/latest | ✔ |
Exchange | /v1/exchange/quotes/historical | - |
Global Metrics | /v1/global-metrics/quotes/latest | - |
Global Metrics | /v1/global-metrics/quotes/historical | - |
Tools | /v1/tools/price-conversion | - |