Awesome Open Source
Awesome Open Source

import "github.com/abrander/coinmarketcap"

This package provides access to the public CoinMarketCap API.

GoDoc Travis Coverage

Overview

This package uses the functional options pattern to ensure that we can upgrade this package without breaking compatibility if the public API ever changes.

Examples

Printing the global market cap in danish kroner

import (
	"fmt"
	"time"

	"github.com/abrander/coinmarketcap"
)

func main() {
	client, _ := coinmarketcap.NewClient()

	globaldata, _ := client.GlobalData(
		coinmarketcap.Convert("DKK"),
	)

	cap, _ := globaldata.MarketCap("DKK")

	fmt.Printf("Global market cap in DKK: %.0f (Updated %s ago)\n",
		cap,
		time.Since(globaldata.LastUpdated),
	)
}

Get the top five changes

import (
	"fmt"

	"github.com/abrander/coinmarketcap"
)

func main() {
	client, _ := coinmarketcap.NewClient()

	coins, _ := client.Ticker(
		coinmarketcap.Limit(5),
	)

	for _, coin := range coins {
		fmt.Printf("%04s %s 1H: %f 24H:%f  7D:%f (%s)\n",
			coin.Symbol,
			coin.ID,
			coin.PercentChange1H,
			coin.PercentChange24H,
			coin.PercentChange7D,
			coin.LastUpdated,
		)
	}
}
Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Golang (164,094
Bindings (17,069
Printing (2,630
Golang Package (990
Bitcoin Price (189
Coinmarketcap (158
Coinmarketcap Api (44
Ethereum Price (9