Documentation
¶
Overview ¶
Package coingecko is the library behind the coingecko command line: the HTTP client, request shaping, and the typed data models for the CoinGecko public API.
The free CoinGecko API requires no key. The client paces requests at a 2-second floor to stay well within the ~30 req/min free-tier limit, and retries transient failures (429 and 5xx) with exponential backoff.
Index ¶
- Constants
- type Client
- func (c *Client) CoinDetail(ctx context.Context, id string) (Coin, error)
- func (c *Client) Markets(ctx context.Context, currency string, limit, page int) ([]Market, error)
- func (c *Client) Price(ctx context.Context, ids []string, currency string) ([]Price, error)
- func (c *Client) Trending(ctx context.Context) ([]Trending, error)
- type Coin
- type Config
- type Domain
- type Market
- type Price
- type Trending
Constants ¶
const Host = "api.coingecko.com"
Host is the site this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to CoinGecko over HTTP.
func (*Client) CoinDetail ¶ added in v0.1.3
CoinDetail returns the full detail object for a single coin.
func (*Client) Markets ¶ added in v0.1.1
Markets returns coins sorted by market cap descending. Pass limit <= 0 for the default (20). page is 1-indexed.
type Coin ¶ added in v0.1.1
type Coin struct {
ID string `kit:"id" json:"id"`
Symbol string `json:"symbol"`
Name string `json:"name"`
Description string `json:"description"`
Price string `json:"price"`
MarketCap string `json:"market_cap"`
Volume24h string `json:"volume_24h"`
High24h string `json:"high_24h"`
Low24h string `json:"low_24h"`
}
Coin is the full coin detail from /coins/{id}.
type Config ¶ added in v0.1.1
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tunable parameters for the Client.
func DefaultConfig ¶ added in v0.1.1
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults for the free tier.
type Domain ¶
type Domain struct{}
Domain is the CoinGecko driver. It carries no state; the per-run client is built by the factory Register hands kit.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.
type Market ¶ added in v0.1.3
type Market struct {
ID string `kit:"id" json:"id"`
Symbol string `json:"symbol"`
Name string `json:"name"`
Rank int `json:"rank"`
Price string `json:"price"`
MarketCap string `json:"market_cap"`
Volume24h string `json:"volume_24h"`
High24h string `json:"high_24h"`
Low24h string `json:"low_24h"`
Change24h string `json:"change_24h_pct"`
}
Market is one entry from the /coins/markets listing.