Categorygithub.com/bufdata/coingecko-api
repository
0.0.1
Repository: https://github.com/bufdata/coingecko-api.git
Documentation: pkg.go.dev

# 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

Go Version Code Lint Unit Test GoDoc goreports Codecov license Build Status

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.

License

MIT