# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# README
CoinGecko API
This library contains two apis:
Installation
go get -u github.com/bufdata/coingecko-api
Usage
CoinGecko
For free API
, you can provide an API Key or not:
package main
import (
"context"
"log/slog"
"github.com/bufdata/coingecko-api/coingecko"
)
func main() {
api := coingecko.NewCoinGecko("your_api_key", false, nil)
data, err := api.ListCoinsInfo(context.Background(), true)
if err != nil {
slog.Error("failed to call ListCoinsInfo", "error", err)
}
slog.Info("call ListSupportedCoinsInfo successfully", "response data", (*data)[0])
}
For users with Pro API Key
:
package main
import (
"context"
"log/slog"
"github.com/bufdata/coingecko-api/coingecko"
)
func main() {
api := coingecko.NewCoinGecko("your_api_key", true, nil)
data, err := api.ListCoinsInfo(context.Background(), true)
if err != nil {
slog.Error("failed to call ListCoinsInfo", "error", err)
}
slog.Info("call ListSupportedCoinsInfo successfully", "response data", (*data)[0])
}
If you use coingecko
library in production, you might need to set your own http.Client
param.
This library has covered all APIs. For detailed APIs info, you can read CoinGecko docs.
Note
The methods in coingecko/paid_methods.go
and coingecko/enterprise_methods.go
are not tested, so if you find there
are some bugs in them, you can raise pr or issue.
GeckoTerminal
package main
import (
"context"
"log/slog"
"github.com/bufdata/coingecko-api/geckoterminal"
)
func main() {
api := geckoterminal.NewGeckoTerminal(nil)
data, err := api.GetNetworks(context.Background(), 0)
if err != nil {
slog.Error("failed to call GetNetworks", "error", err)
}
slog.Info("call GetNetworks successfully", "response data", *data)
}
If you use geckoterminal
library in production, you might need to set your own http.Client
param.
This library has covered all APIs. For detailed APIs info, you can read GeckoTerminal API.