coingecko

package module
v0.0.0-...-d5f1921 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: MIT Imports: 12 Imported by: 0

README

Coingecko

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OrderTypeObject = &OrderType{
	MarketCapDesc: "market_cap_desc",
	MarketCapAsc:  "market_cap_asc",
	GeckoDesc:     "gecko_desc",
	GeckoAsc:      "gecko_asc",
	VolumeAsc:     "volume_asc",
	VolumeDesc:    "volume_desc",
}

OrderTypeObject for certain order

View Source
var PriceChangePercentageObject = &PriceChangePercentage{
	PCP1h:   "1h",
	PCP24h:  "24h",
	PCP7d:   "7d",
	PCP14d:  "14d",
	PCP30d:  "30d",
	PCP200d: "200d",
	PCP1y:   "1y",
}

PriceChangePercentageObject for different amount of time

Functions

func Bool2String

func Bool2String(b bool) string

Bool2String boolean to string

func Int2String

func Int2String(i int) string

Int2String Integer to string

Types

type AllCurrencies

type AllCurrencies map[string]float64

AllCurrencies map all currencies (USD, BTC) to float64

type CategoriesItem

type CategoriesItem struct {
	ID                 string    `json:"id"`
	Name               string    `json:"name"`
	MarketCap          float64   `json:"market_cap"`
	MarketCapChange24H float64   `json:"market_cap_change_24h"`
	Content            string    `json:"content"`
	Top3Coins          []string  `json:"top_3_coins"`
	Volume24H          float64   `json:"volume_24h"`
	UpdatedAt          time.Time `json:"updated_at"`
}

type CategoriesListItem

type CategoriesListItem struct {
	ID   string `json:"category_id"`
	Name string `json:"name"`
}

type Client

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

Client struct

func NewClient

func NewClient(cfg Config) *Client

NewClient create new client object

func (*Client) Categories

func (c *Client) Categories(ctx context.Context) (data []CategoriesItem, err error)

func (*Client) CategoriesList

func (c *Client) CategoriesList(ctx context.Context) (data []CategoriesListItem, err error)

func (*Client) CoinsID

func (c *Client) CoinsID(ctx context.Context, r CoinsIDRequest) (data *CoinsID, err error)

CoinsID /coins/{id}

func (*Client) CoinsIDHistory

func (c *Client) CoinsIDHistory(ctx context.Context, id string, date string, localization bool) (data *CoinsIDHistory, err error)

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

func (*Client) CoinsIDMarketChart

func (c *Client) CoinsIDMarketChart(ctx context.Context, req CoinsIDMarketChartRequest) (data *CoinsIDMarketChart, err error)

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

func (*Client) CoinsIDTickers

func (c *Client) CoinsIDTickers(ctx context.Context, r CoinsIDTickersRequest) (data *CoinsIDTickers, err error)

CoinsIDTickers /coins/{id}/tickers

func (*Client) CoinsList

func (c *Client) CoinsList(ctx context.Context) (data []CoinBaseStruct, err error)

CoinsList /coins/list

func (*Client) CoinsMarket

func (c *Client) CoinsMarket(ctx context.Context, req CoinsMarketRequest) (data []CoinsMarketItem, err error)

CoinsMarket /coins/market

func (*Client) ExchangeRates

func (c *Client) ExchangeRates(ctx context.Context) (data *ExchangeRatesItem, err error)

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

func (*Client) Exchanges

func (c *Client) Exchanges(ctx context.Context, perPage int, page int) (data []ExchangesItem, err error)

func (*Client) ExchangesID

func (c *Client) ExchangesID(ctx context.Context, id string) (data []ExchangesItem, err error)

func (*Client) Global

func (c *Client) Global(ctx context.Context) (data *Global, err error)

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

func (*Client) MakeReq

func (c *Client) MakeReq(ctx context.Context, url string, data interface{}) error

MakeReq HTTP request helper

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) (data *Ping, err error)

Ping /ping endpoint

func (*Client) Search

func (c *Client) Search(ctx context.Context, query string) (data *SearchResponse, err error)

Search https://api.coingecko.com/api/v3/search

func (*Client) SimplePrice

func (c *Client) SimplePrice(ctx context.Context, ids []string, vsCurrencies []string) (*map[string]map[string]float32, error)

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

func (*Client) SimpleSinglePrice

func (c *Client) SimpleSinglePrice(ctx context.Context, id string, vsCurrency string) (*SimpleSinglePrice, error)

SimpleSinglePrice /simple/price Single ID and Currency (ids, vs_currency)

func (*Client) SimpleSupportedVSCurrencies

func (c *Client) SimpleSupportedVSCurrencies(ctx context.Context) (data *SimpleSupportedVSCurrencies, err error)

SimpleSupportedVSCurrencies /simple/supported_vs_currencies

type Coin

type Coin struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	Symbol        string `json:"symbol"`
	MarketCapRank int64  `json:"market_cap_rank"`
	Thumb         string `json:"thumb"`
	Large         string `json:"large"`
}

type CoinBaseStruct

type CoinBaseStruct struct {
	ID     string `json:"id"`
	Symbol string `json:"symbol"`
	Name   string `json:"name"`
}

CoinBaseStruct [private]

type CoinsID

type CoinsID struct {
	ID                           string              `json:"id"`
	Symbol                       string              `json:"symbol"`
	Name                         string              `json:"name"`
	BlockTimeInMin               int32               `json:"block_time_in_minutes"`
	HashingAlgorithm             string              `json:"hashing_algorithm"`
	Categories                   []string            `json:"categories"`
	Localization                 *LocalizationItem   `json:"localization,omitempty"`
	Description                  DescriptionItem     `json:"description"`
	Links                        *LinksItem          `json:"links"`
	Image                        ImageItem           `json:"image"`
	CountryOrigin                string              `json:"country_origin"`
	GenesisDate                  string              `json:"genesis_date"`
	SentimentVotesUpPercentage   float64             `json:"sentiment_votes_up_percentage"`
	SentimentVotesDownPercentage float64             `json:"sentiment_votes_down_percentage"`
	MarketCapRank                uint16              `json:"market_cap_rank"`
	CoinGeckoRank                uint16              `json:"coingecko_rank"`
	CoinGeckoScore               float32             `json:"coingecko_score"`
	DeveloperScore               float32             `json:"developer_score"`
	CommunityScore               float32             `json:"community_score"`
	LiquidityScore               float32             `json:"liquidity_score"`
	PublicInterestScore          float32             `json:"public_interest_score"`
	MarketData                   *MarketDataItem     `json:"market_data"`
	CommunityData                *CommunityDataItem  `json:"community_data,omitempty"`
	DeveloperData                *DeveloperDataItem  `json:"developer_data,omitempty"`
	PublicInterestStats          *PublicInterestItem `json:"public_interest_stats"`
	StatusUpdates                *[]StatusUpdateItem `json:"status_updates,omitempty"`
	LastUpdated                  time.Time           `json:"last_updated"`
	Tickers                      *[]TickerItem       `json:"tickers,omitempty"`
}

CoinsID https://api.coingecko.com/api/v3/coins/bitcoin

type CoinsIDHistory

type CoinsIDHistory struct {
	CoinBaseStruct
	Localization   LocalizationItem    `json:"localization"`
	Image          ImageItem           `json:"image"`
	MarketData     *MarketDataItem     `json:"market_data"`
	CommunityData  *CommunityDataItem  `json:"community_data"`
	DeveloperData  *DeveloperDataItem  `json:"developer_data"`
	PublicInterest *PublicInterestItem `json:"public_interest_stats"`
}

CoinsIDHistory https://api.coingecko.com/api/v3/coins/steem/history?date=30-12-2018

type CoinsIDMarketChart

type CoinsIDMarketChart struct {
	Prices       [][2]float64 `json:"prices,omitempty"`
	MarketCaps   [][2]float64 `json:"market_caps,omitempty"`
	TotalVolumes [][2]float64 `json:"total_volumes,omitempty"`
}

type CoinsIDMarketChartRequest

type CoinsIDMarketChartRequest struct {
	ID         string `json:"id"`
	VsCurrency string `json:"vs_currency"`
	Days       string `json:"days"`
	Interval   string `json:"interval"`
}

CoinsIDMarketChart https://api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=usd&days=1

type CoinsIDRequest

type CoinsIDRequest struct {
	ID            string `json:"id"`
	Localization  bool   `json:"localization"`
	Tickers       bool   `json:"tickers"`
	MarketData    bool   `json:"market_data"`
	CommunityData bool   `json:"community_data"`
	DeveloperData bool   `json:"developer_data"`
	Sparkline     bool   `json:"sparkline"`
}

type CoinsIDTickers

type CoinsIDTickers struct {
	Name    string       `json:"name"`
	Tickers []TickerItem `json:"tickers"`
}

CoinsIDTickers https://api.coingecko.com/api/v3/coins/steem/tickers?page=1

type CoinsIDTickersOrder

type CoinsIDTickersOrder string
var (
	TrustScoreDesc CoinsIDTickersOrder = "trust_score_desc"
	TrustScoreAsc  CoinsIDTickersOrder = "trust_score_asc"
	VolumeDesc     CoinsIDTickersOrder = "volume_desc"
)

type CoinsIDTickersRequest

type CoinsIDTickersRequest struct {
	ID          string              `json:"id"`
	ExchangeIds []string            `json:"exchange_ids"`
	Page        int                 `json:"page"`
	Order       CoinsIDTickersOrder `json:"order"`
	Depth       bool                `json:"depth"`
}

type CoinsMarketItem

type CoinsMarketItem struct {
	ID                    string  `json:"id"`
	Symbol                string  `json:"symbol"`
	Name                  string  `json:"name"`
	Image                 string  `json:"image"`
	CurrentPrice          float64 `json:"current_price"`
	MarketCap             float64 `json:"market_cap"`
	MarketCapRank         int64   `json:"market_cap_rank"`
	FullyDilutedValuation *int64  `json:"fully_diluted_valuation,omitempty"`

	TotalVolume              float64 `json:"total_volume"`
	High24                   float64 `json:"high_24h"`
	Low24                    float64 `json:"low_24h"`
	PriceChange24h           float64 `json:"price_change_24h"`
	PriceChangePercentage24h float64 `json:"price_change_percentage_24h"`

	MarketCapChange24h           float64 `json:"market_cap_change_24h"`
	MarketCapChangePercentage24h float64 `json:"market_cap_change_percentage_24h"`

	CirculatingSupply *float64 `json:"circulating_supply,omitempty"`
	TotalSupply       *float64 `json:"total_supply,omitempty"`
	MaxSupply         *float64 `json:"max_supply,omitempty"`

	ATH float64 `json:"ath"`
	//the drop in percents of the price of a cryptocurrency compared to its maximum price (ATH) of all time
	ATHChangePercentage float64   `json:"ath_change_percentage"`
	ATHDate             time.Time `json:"ath_date"`
	ATL                 float64   `json:"atl"`
	ATLChangePercentage float64   `json:"atl_change_percentage"`
	ATLDate             time.Time `json:"atl_date"`

	LastUpdated                         time.Time      `json:"last_updated"`
	PriceChangePercentage1hInCurrency   *float64       `json:"price_change_percentage_1h_in_currency,omitempty"`
	PriceChangePercentage24hInCurrency  *float64       `json:"price_change_percentage_24h_in_currency,omitempty"`
	PriceChangePercentage7dInCurrency   *float64       `json:"price_change_percentage_7d_in_currency,omitempty"`
	PriceChangePercentage14dInCurrency  *float64       `json:"price_change_percentage_14d_in_currency,omitempty"`
	PriceChangePercentage30dInCurrency  *float64       `json:"price_change_percentage_30d_in_currency,omitempty"`
	PriceChangePercentage200dInCurrency *float64       `json:"price_change_percentage_200d_in_currency,omitempty"`
	PriceChangePercentage1yInCurrency   *float64       `json:"price_change_percentage_1y_in_currency,omitempty"`
	ROI                                 *ROIItem       `json:"roi,omitempty"`
	SparklineIn7d                       *SparklineItem `json:"sparkline_in_7d,omitempty"`
}

CoinsMarketItem item in CoinMarket

type CoinsMarketRequest

type CoinsMarketRequest struct {
	VsCurrency            string
	Ids                   []string
	Order                 string
	PerPage               int
	Page                  int
	Sparkline             bool
	PriceChangePercentage []string
}

type CommunityDataItem

type CommunityDataItem struct {
	FacebookLikes            *uint    `json:"facebook_likes,omitempty"`
	TwitterFollowers         *uint    `json:"twitter_followers,omitempty"`
	RedditAveragePosts48h    *float64 `json:"reddit_average_posts_48h,omitempty"`
	RedditAverageComments48h *float64 `json:"reddit_average_comments_48h,omitempty"`
	RedditSubscribers        *uint    `json:"reddit_subscribers,omitempty"`
	RedditAccountsActive48h  *uint    `json:"reddit_accounts_active_48h,omitempty"`
	TelegramChannelUserCount *uint    `json:"telegram_channel_user_count,omitempty"`
}

CommunityDataItem map all community data item

type Config

type Config struct {
	BaseUrl     string
	Debug       bool
	HttpClient  *http.Client
	RateLimiter *rate.Limiter
}

type DescriptionItem

type DescriptionItem map[string]string

TYPES DescriptionItem map all description (in locale) into respective string

type DeveloperDataItem

type DeveloperDataItem struct {
	Forks              *uint `json:"forks"`
	Stars              *uint `json:"stars"`
	Subscribers        *uint `json:"subscribers"`
	TotalIssues        *uint `json:"total_issues"`
	ClosedIssues       *uint `json:"closed_issues"`
	PRMerged           *uint `json:"pull_requests_merged"`
	PRContributors     *uint `json:"pull_request_contributors"`
	CommitsCount4Weeks *uint `json:"commit_count_4_weeks"`
}

DeveloperDataItem map all developer data item

type EventCountryItem

type EventCountryItem struct {
	Country string `json:"country"`
	Code    string `json:"code"`
}

EventCountryItem item in EventsCountries

type EventsCountries

type EventsCountries struct {
	Data []EventCountryItem `json:"data"`
}

EventsCountries https://api.coingecko.com/api/v3/events/countries

type EventsTypes

type EventsTypes struct {
	Data  []string `json:"data"`
	Count uint16   `json:"count"`
}

EventsTypes https://api.coingecko.com/api/v3/events/types

type ExchangeRatesItem

type ExchangeRatesItem map[string]ExchangeRatesItemStruct

ExchangeRatesItem item in ExchangeRate

type ExchangeRatesItemStruct

type ExchangeRatesItemStruct struct {
	Name  string  `json:"name"`
	Unit  string  `json:"unit"`
	Value float64 `json:"value"`
	Type  string  `json:"type"`
}

ExchangeRatesItemStruct struct in ExchangeRateItem

type ExchangeRatesResponse

type ExchangeRatesResponse struct {
	Rates ExchangeRatesItem `json:"rates"`
}

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

type ExchangesItem

type ExchangesItem struct {
	ID                          string  `json:"id"`
	Name                        string  `json:"name"`
	YearEstablished             int64   `json:"year_established"`
	Country                     string  `json:"country"`
	Description                 string  `json:"description"`
	Url                         string  `json:"url"`
	Image                       string  `json:"image"`
	HasTradingIncentive         bool    `json:"has_trading_incentive"`
	TrustScore                  int64   `json:"trust_score"`
	TrustScoreRank              int64   `json:"trust_score_rank"`
	TradeVolume24HBtc           float64 `json:"trade_volume_24h_btc"`
	TradeVolume24HBtcNormalized float64 `json:"trade_volume_24h_btc_normalized"`
}

type Global

type Global struct {
	ActiveCryptocurrencies          uint16        `json:"active_cryptocurrencies"`
	UpcomingICOs                    uint16        `json:"upcoming_icos"`
	OngoingICOs                     uint16        `json:"ongoing_icos"`
	EndedICOs                       uint16        `json:"ended_icos"`
	Markets                         uint16        `json:"markets"`
	MarketCapChangePercentage24hUSD float32       `json:"market_cap_change_percentage_24h_usd"`
	TotalMarketCap                  AllCurrencies `json:"total_market_cap"`
	TotalVolume                     AllCurrencies `json:"total_volume"`
	MarketCapPercentage             AllCurrencies `json:"market_cap_percentage"`
	UpdatedAt                       int64         `json:"updated_at"`
}

Global for data of /global

type GlobalResponse

type GlobalResponse struct {
	Data Global `json:"data"`
}

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

type ImageItem

type ImageItem struct {
	Thumb string `json:"thumb"`
	Small string `json:"small"`
	Large string `json:"large"`
}

ImageItem struct for all sizes of image

type LinksItem

type LinksItem map[string]interface{}

LinksItem map all links

type LocalizationItem

type LocalizationItem map[string]string

LocalizationItem map all locale (en, zh) into respective string

type MarketDataItem

type MarketDataItem struct {
	CurrentPrice                           AllCurrencies     `json:"current_price"`
	ROI                                    *ROIItem          `json:"roi"`
	ATH                                    AllCurrencies     `json:"ath"`
	ATHChangePercentage                    AllCurrencies     `json:"ath_change_percentage"`
	ATHDate                                map[string]string `json:"ath_date"`
	ATL                                    AllCurrencies     `json:"atl"`
	ATLChangePercentage                    AllCurrencies     `json:"atl_change_percentage"`
	ATLDate                                map[string]string `json:"atl_date"`
	MarketCap                              AllCurrencies     `json:"market_cap"`
	MarketCapRank                          uint16            `json:"market_cap_rank"`
	TotalVolume                            AllCurrencies     `json:"total_volume"`
	High24                                 AllCurrencies     `json:"high_24h"`
	Low24                                  AllCurrencies     `json:"low_24h"`
	PriceChange24h                         float64           `json:"price_change_24h"`
	PriceChangePercentage24h               float64           `json:"price_change_percentage_24h"`
	PriceChangePercentage7d                float64           `json:"price_change_percentage_7d"`
	PriceChangePercentage14d               float64           `json:"price_change_percentage_14d"`
	PriceChangePercentage30d               float64           `json:"price_change_percentage_30d"`
	PriceChangePercentage60d               float64           `json:"price_change_percentage_60d"`
	PriceChangePercentage200d              float64           `json:"price_change_percentage_200d"`
	PriceChangePercentage1y                float64           `json:"price_change_percentage_1y"`
	MarketCapChange24h                     float64           `json:"market_cap_change_24h"`
	MarketCapChangePercentage24h           float64           `json:"market_cap_change_percentage_24h"`
	PriceChange24hInCurrency               AllCurrencies     `json:"price_change_24h_in_currency"`
	PriceChangePercentage1hInCurrency      AllCurrencies     `json:"price_change_percentage_1h_in_currency"`
	PriceChangePercentage24hInCurrency     AllCurrencies     `json:"price_change_percentage_24h_in_currency"`
	PriceChangePercentage7dInCurrency      AllCurrencies     `json:"price_change_percentage_7d_in_currency"`
	PriceChangePercentage14dInCurrency     AllCurrencies     `json:"price_change_percentage_14d_in_currency"`
	PriceChangePercentage30dInCurrency     AllCurrencies     `json:"price_change_percentage_30d_in_currency"`
	PriceChangePercentage60dInCurrency     AllCurrencies     `json:"price_change_percentage_60d_in_currency"`
	PriceChangePercentage200dInCurrency    AllCurrencies     `json:"price_change_percentage_200d_in_currency"`
	PriceChangePercentage1yInCurrency      AllCurrencies     `json:"price_change_percentage_1y_in_currency"`
	MarketCapChange24hInCurrency           AllCurrencies     `json:"market_cap_change_24h_in_currency"`
	MarketCapChangePercentage24hInCurrency AllCurrencies     `json:"market_cap_change_percentage_24h_in_currency"`
	TotalSupply                            *float64          `json:"total_supply"`
	CirculatingSupply                      float64           `json:"circulating_supply"`
	Sparkline                              *SparklineItem    `json:"sparkline_7d"`
	LastUpdated                            string            `json:"last_updated"`
}

MarketDataItem map all market data item

type OrderType

type OrderType struct {
	MarketCapDesc string
	MarketCapAsc  string
	GeckoDesc     string
	GeckoAsc      string
	VolumeAsc     string
	VolumeDesc    string
}

OrderType in CoinGecko

type Ping

type Ping struct {
	GeckoSays string `json:"gecko_says"`
}

Ping https://api.coingecko.com/api/v3/ping

type PriceChangePercentage

type PriceChangePercentage struct {
	PCP1h   string
	PCP24h  string
	PCP7d   string
	PCP14d  string
	PCP30d  string
	PCP200d string
	PCP1y   string
}

PriceChangePercentage in different amount of time

type PublicInterestItem

type PublicInterestItem struct {
	AlexaRank   *uint `json:"alexa_rank,omitempty"`
	BingMatches *uint `json:"bing_matches,omitempty"`
}

PublicInterestItem map all public interest item

type ROIItem

type ROIItem struct {
	Times      float64 `json:"times"`
	Currency   string  `json:"currency"`
	Percentage float64 `json:"percentage"`
}

ROIItem ROI Item

type SearchResponse

type SearchResponse struct {
	Coins      []Coin        `json:"coins"`
	Exchanges  []interface{} `json:"exchanges"`
	Icos       []interface{} `json:"icos"`
	Categories []interface{} `json:"categories"`
}

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

type SimpleSinglePrice

type SimpleSinglePrice struct {
	ID          string
	Currency    string
	MarketPrice float32
}

SimpleSinglePrice https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd

type SimpleSupportedVSCurrencies

type SimpleSupportedVSCurrencies []string

SimpleSupportedVSCurrencies https://api.coingecko.com/api/v3/simple/supported_vs_currencies

type SparklineItem

type SparklineItem struct {
	Price []float64 `json:"price"`
}

SparklineItem for sparkline

type StatusUpdateItem

type StatusUpdateItem struct {
	Description string `json:"description"`
	Category    string `json:"category"`
	CreatedAt   string `json:"created_at"`
	User        string `json:"user"`
	UserTitle   string `json:"user_title"`
	Pin         bool   `json:"pin"`
	Project     struct {
		CoinBaseStruct
		Type  string    `json:"type"`
		Image ImageItem `json:"image"`
	} `json:"project"`
}

StatusUpdateItem for BEAM

type TickerItem

type TickerItem struct {
	Base   string `json:"base"`
	Target string `json:"target"`
	Market struct {
		Name             string `json:"name"`
		Identifier       string `json:"identifier"`
		TradingIncentive bool   `json:"has_trading_incentive"`
	} `json:"market"`
	Last   float64 `json:"last"`
	Volume float64 `json:"volume"`

	//ConvertedLast   map[string]float64 `json:"converted_last"`
	ConvertedLast struct {
		BTC float64 `json:"btc"`
		ETH float64 `json:"eth"`
		USD float64 `json:"usd"`
	} `json:"converted_last"`
	//ConvertedVolume map[string]float64 `json:"converted_volume"`
	ConvertedVolume struct {
		BTC float64 `json:"btc"`
		ETH float64 `json:"eth"`
		USD float64 `json:"usd"`
	} `json:"converted_volume"`
	TrustScore             string    `json:"trust_score"`
	BidAskSpreadPercentage float64   `json:"bid_ask_spread_percentage"`
	LastTradedAt           time.Time `json:"last_traded_at"`
	LastFetchAt            time.Time `json:"last_fetch_at"`

	Timestamp    time.Time `json:"timestamp"`
	IsAnomaly    bool      `json:"is_anomaly"`
	IsStale      bool      `json:"is_stale"`
	CoinID       string    `json:"coin_id"`
	TargetCoinId string    `json:"target_coin_id"`
}

TickerItem for ticker

Jump to

Keyboard shortcuts

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