coingecko

package
v0.0.0-...-6e2b219 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client struct

func NewClient

func NewClient(httpClient *http.Client, options ...ClientOption) *Client

NewClient create new client object

func (*Client) CoinsID

func (c *Client) CoinsID(params CoinsIDParams) (*types.CoinsID, error)

CoinsID /coins/{id}

func (*Client) CoinsIDHistory

func (c *Client) CoinsIDHistory(params CoinsIDHistoryParams) (*types.CoinsIDHistory, error)

CoinsIDHistory /coins/{id}/history?date={date}&localization=false

func (*Client) CoinsIDMarketChart

func (c *Client) CoinsIDMarketChart(params CoinsIDMarketChartParams) (*types.CoinsIDMarketChart, error)

CoinsIDMarketChart /coins/{id}/market_chart?vs_currency={usd, eur, jpy, etc.}&days={1,14,30,max}

func (*Client) CoinsIDTickers

func (c *Client) CoinsIDTickers(params CoinsIDTickersParam) (*types.CoinsIDTickers, error)

CoinsIDTickers /coins/{id}/tickers

func (*Client) CoinsList

func (c *Client) CoinsList() (*types.CoinsList, error)

CoinsList /coins/list

func (*Client) CoinsMarkets

func (c *Client) CoinsMarkets(params CoinsMarketParams) (*types.CoinsMarkets, error)

CoinsMarkets /coins/markets

func (*Client) ExchangeRates

func (c *Client) ExchangeRates() (*types.ExchangeRates, error)

ExchangeRates https://api.coingecko.com/api/v3/exchange_rates

func (*Client) Exchanges

func (c *Client) Exchanges(params ExchangesParam) (*types.Exchanges, error)

Exchanges https://api.coingecko.com/api/v3/exchanges

func (*Client) ExchangesID

func (c *Client) ExchangesID(exchangeID string) (*types.ExchangeDetail, error)

func (*Client) ExchangesIDTickers

func (c *Client) ExchangesIDTickers(params ExchangesIDTickersParams) (*types.ExchangeTickers, error)

func (*Client) ExchangesList

func (c *Client) ExchangesList() (*types.ExchangesList, error)

ExchangesList https://api.coingecko.com/api/v3/exchanges/list

func (*Client) Global

func (c *Client) Global() (*types.Global, error)

Global https://api.coingecko.com/api/v3/global

func (*Client) Ping

func (c *Client) Ping() (*types.Ping, error)

Ping /ping endpoint

func (*Client) SimplePrice

func (c *Client) SimplePrice(params SimplePriceParams) (*types.SimplePrice, error)

SimplePrice /simple/price Multiple ID and Currency (ids, vs_currencies)

func (*Client) SimpleSupportedVSCurrencies

func (c *Client) SimpleSupportedVSCurrencies() (*types.SimpleSupportedVSCurrencies, error)

SimpleSupportedVSCurrencies /simple/supported_vs_currencies

type ClientOption

type ClientOption func(client *Client)

func WithAPIKey

func WithAPIKey(apiKey string) ClientOption

func WithHttpRequestModifier

func WithHttpRequestModifier(f HttpRequestModifier) ClientOption

type CoinsIDHistoryParams

type CoinsIDHistoryParams struct {
	CoinID       string `json:"coin_id"`       // CoinID (can be obtained from /coins)
	SnapshotDate string `json:"snapshot_date"` // The date of data snapshot in dd-mm-yyyy eg. 30-12-2017
	Localization bool   `json:"localization"`  // Set to false to exclude localized languages in response
}

func (CoinsIDHistoryParams) Validate

func (p CoinsIDHistoryParams) Validate() error

type CoinsIDMarketChartParams

type CoinsIDMarketChartParams struct {
	CoinsID    string `json:"coins_id"`    // CoinID (can be obtained from /coins)
	VsCurrency string `json:"vs_currency"` // The target currency of market data (usd, eur, jpy, etc.)
	Days       string `json:"days"`        // Data up to number of days ago (eg. 1,14,30,max)
}

func (CoinsIDMarketChartParams) Validate

func (p CoinsIDMarketChartParams) Validate() error

type CoinsIDParams

type CoinsIDParams struct {
	CoinID        string `json:"coin_id"`        // CoinID (can be obtained from /coins)
	Localization  bool   `json:"localization"`   // Include all localized languages in response
	Tickers       bool   `json:"tickers"`        // Include tickers data. If true returns up to 100 entries. Use CoinsIDTickers
	MarketData    bool   `json:"market_data"`    // Include market data
	CommunityData bool   `json:"community_data"` // Include community data
	DeveloperData bool   `json:"developer_data"` // Include developer data
	Sparkline     bool   `json:"sparkline"`      // Include sparkline 7 days data
}

func (CoinsIDParams) Validate

func (c CoinsIDParams) Validate() error

type CoinsIDTickersParam

type CoinsIDTickersParam struct {
	CoinsID                string            `json:"coins_id"`                    // CoinID (can be obtained from /coins)
	ExchangeIDs            []string          `json:"exchange_ids"`                // filter results by exchange_ids ExchangesList
	PageNo                 int               `json:"page_no"`                     // Page through results
	Order                  types.TickerOrder `json:"order"`                       // If not set default to trust_score_desc
	Show2PctOrderBookDepth bool              `json:"show_2_pct_order_book_depth"` // flag to show 2% order book depth
}

func (CoinsIDTickersParam) Validate

func (p CoinsIDTickersParam) Validate() error

type CoinsMarketParams

type CoinsMarketParams struct {
	VsCurrency            string                        `json:"vs_currency"` // Required. The target currency of market data (usd, eur, jpy, etc.)
	CoinIDs               []string                      `json:"coin_ids"`    // The ids of the coin, crytocurrency symbols (base). refers to /coins/list.
	Category              string                        `json:"category"`    // filter by coin category. Refer to /coin/categories/list
	Order                 types.CoinsMarketOrder        `json:"order"`       // When blank will be set to "market_cap_desc"
	PageSize              int                           `json:"page_size"`   // Starts from 1 - 250, when invalid will be set to 100
	PageNo                int                           `json:"page_no"`     // Starts from 1, when < 1, will be set to 1
	Sparkline             bool                          `json:"sparkline"`   // Include sparkline 7 days data (eg. true, false)
	PriceChangePercentage []types.PriceChangePercentage `json:"price_change_percentage"`
}

func (CoinsMarketParams) Validate

func (p CoinsMarketParams) Validate() error

type ExchangesIDTickersParams

type ExchangesIDTickersParams struct {
	ExchangeID             string            `json:"exchange_id"`                 // ExchangeID, can be obtained from ExchangesList. Required.
	CoinIds                []string          `json:"coin_ids"`                    // filter tickers by CoinIds (ref: CoinsList). Optional.
	PageNo                 int               `json:"page_no"`                     // Page through results. If < 1, default to 1.
	Show2PctOrderBookDepth bool              `json:"show_2_pct_order_book_depth"` // flag to show 2% orderbook depth i.e., CostToMoveUpUsd and CostToMoveDownUsd
	Order                  types.TickerOrder `json:"order"`                       // Default to TickerOrderTrustScoreDesc
}

func (ExchangesIDTickersParams) Valid

func (p ExchangesIDTickersParams) Valid() error

type ExchangesParam

type ExchangesParam struct {
	PageSize int `json:"page_size"` // Total results per page, between 1-250. When invalid, default to 100.
	PageNo   int `json:"page_no"`   // Page through results. Valid values bigger than 1. When invalid, default to 1.
}

type HttpRequestModifier

type HttpRequestModifier func(r *http.Request)

type SimplePriceParams

type SimplePriceParams struct {
	CoinIDs           []string `json:"coin_ids"`             // CoinIds refers to CoinsList
	VsCurrencies      []string `json:"vs_currencies"`        // VsCurrencies refers to SimpleSupportedVSCurrencies
	MarketCap         bool     `json:"market_cap"`           // Sets to true to include market cap. Default false.
	Include24HrVolume bool     `json:"include_24_hr_volume"` // Sets to true to include 24 Hr volume. Default false.
	Include24HrChange bool     `json:"include_24_hr_change"` // Sets to true to include 24 Hr change. Default false.
	LastUpdatedAt     bool     `json:"last_updated_at"`      // Sets to true to include last updated at. Default false.
	Precision         string   `json:"precision"`            // valid values: empty string, "full", an int [0,18]
}

func (SimplePriceParams) Valid

func (params SimplePriceParams) Valid() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址