Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abrander/coinmarketcap
Go bindings for the coinmarketcap API
https://github.com/abrander/coinmarketcap
bitcoin-price coinmarketcap coinmarketcap-api ethereum-price golang golang-package
Last synced: about 1 month ago
JSON representation
Go bindings for the coinmarketcap API
- Host: GitHub
- URL: https://github.com/abrander/coinmarketcap
- Owner: abrander
- License: mit
- Created: 2017-12-17T15:00:36.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-17T22:29:25.000Z (almost 7 years ago)
- Last Synced: 2024-06-20T14:17:03.203Z (7 months ago)
- Topics: bitcoin-price, coinmarketcap, coinmarketcap-api, ethereum-price, golang, golang-package
- Language: Go
- Size: 33.2 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `import "github.com/abrander/coinmarketcap"`
This package provides access to the public [CoinMarketCap](https://coinmarketcap.com/) [API](https://coinmarketcap.com/api/).
[![GoDoc][1]][2]
[![Travis][3]][4]
[![Coverage][5]][6][1]: https://godoc.org/github.com/abrander/coinmarketcap?status.svg
[2]: https://godoc.org/github.com/abrander/coinmarketcap[3]: https://travis-ci.org/abrander/coinmarketcap.svg?branch=master
[4]: https://travis-ci.org/abrander/coinmarketcap[5]: https://coveralls.io/repos/github/abrander/coinmarketcap/badge.svg?branch=master
[6]: https://coveralls.io/github/abrander/coinmarketcap?branch=master## Overview
This package uses the [functional options pattern](https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis)
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
```golang
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
```go
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,
)
}
}
```