Simple API Client for CoinGecko written in Go
gopher resources from free-gophers-pack
Refer to CoinGecko official API
Endpoint | Status | Testing | Function |
---|---|---|---|
/ping | [/] | [/] | Ping |
/simple/price | [/] | [/] | SimpleSinglePrice, SimplePrice |
/simple/supported_vs_currencies | [/] | [/] | SimpleSupportedVSCurrencies |
/coins/list | [/] | [/] | CoinsList |
/coins/market | [/] | [/] | CoinsMarket |
/coins/{id} | [/] | CoinsID | |
/coins/{id}/history | [/] | CoinsIDHistory | |
/coins/{id}/market_chart | [/] | CoinsIDMarketChart | |
/events/countries | [/] | EventsCountries | |
/events/types | [/] | EventsType | |
/exchange_rates | [/] | ExchangeRate | |
/global | [/] | Global |
Installation:
Add the following line to your project go.mod
file.
replace github.com/superoo7/go-gecko => github.com/KYRDTeam/go-gecko latest
and run
go mod tidy
to evaluate latest
to a concrete tag.
For usage, checkout Example folder for v3
For production, you might need to set time out for httpClient, here's a sample code:
package main
import (
"net/http"
"time"
coingecko "github.com/superoo7/go-gecko/v3"
)
func main() {
httpClient := &http.Client{
Timeout: time.Second * 10,
}
CG := coingecko.NewClient(httpClient, nil)
c, err := CG.CoinsList(false)
if err != nil {
log.Fatal(err)
}
fmt.Println(c)
}
refer to https://medium.com/@marcus.olsson/writing-a-go-client-for-your-restful-api-c193a2f4998c
MIT