coinmarketcap

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package coinmarketcap Coin Market Cap API client for Go

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTypeAssertion is type assertion error
	ErrTypeAssertion = errors.New("type assertion error")
)
View Source
var SortOptions sortOptions

SortOptions sort options

Functions

This section is empty.

Types

type Client

type Client struct {
	Cryptocurrency *CryptocurrencyService
	Fiat           *FiatService
	Exchange       *ExchangeService
	GlobalMetrics  *GlobalMetricsService
	Tools          *ToolsService
	// contains filtered or unexported fields
}

Client the CoinMarketCap client

func NewClient

func NewClient(cfg *Config) *Client

NewClient initializes a new client

type Config

type Config struct {
	ProAPIKey string
}

Config the client config structure

type ConvertListing

type ConvertListing struct {
	ID          int                      `json:"id"`
	Name        string                   `json:"name"`
	Symbol      string                   `json:"symbol"`
	Amount      float64                  `json:"amount"`
	LastUpdated string                   `json:"last_updated"`
	Quote       map[string]*ConvertQuote `json:"quote"`
}

ConvertListing is the converted listing structure

type ConvertOptions

type ConvertOptions struct {
	Amount    float64
	ID        string
	Symbol    string
	Time      int
	Convert   string
	ConvertID string
}

ConvertOptions options

type ConvertQuote

type ConvertQuote struct {
	Price       float64 `json:"price"`
	LastUpdated string  `json:"last_updated"`
}

ConvertQuote is the converted listing structure

type CryptocurrencyInfo

type CryptocurrencyInfo struct {
	ID       float64                `json:"id"`
	Name     string                 `json:"name"`
	Symbol   string                 `json:"symbol"`
	Category string                 `json:"category"`
	Slug     string                 `json:"slug"`
	Tags     []string               `json:"tags"`
	Urls     map[string]interface{} `json:"urls"`
}

CryptocurrencyInfo options

type CryptocurrencyService

type CryptocurrencyService service

CryptocurrencyService ...

func (*CryptocurrencyService) HistoricalOHLCV

func (s *CryptocurrencyService) HistoricalOHLCV() error

HistoricalOHLCV NOT IMPLEMENTED

func (*CryptocurrencyService) HistoricalQuotes

func (s *CryptocurrencyService) HistoricalQuotes() error

HistoricalQuotes NOT IMPLEMENTED

func (*CryptocurrencyService) Info

Info returns all static metadata for one or more cryptocurrencies including name, symbol, logo, and its various registered URLs.

func (*CryptocurrencyService) LatestListings

func (s *CryptocurrencyService) LatestListings(options *ListingOptions) ([]*Listing, error)

LatestListings gets a paginated list of all cryptocurrencies with latest market data. You can configure this call to sort by market cap or another market ranking field. Use the "convert" option to return market values in multiple fiat and cryptocurrency conversions in the same call.

func (*CryptocurrencyService) LatestMarketPairs

func (s *CryptocurrencyService) LatestMarketPairs(options *MarketPairOptions) (*MarketPairs, error)

LatestMarketPairs Lists all market pairs across all exchanges for the specified cryptocurrency with associated stats. Use the "convert" option to return market values in multiple fiat and cryptocurrency conversions in the same call.

func (*CryptocurrencyService) LatestQuotes

func (s *CryptocurrencyService) LatestQuotes(options *QuoteOptions) ([]*QuoteLatest, error)

LatestQuotes gets latest quote for each specified symbol. Use the "convert" option to return market values in multiple fiat and cryptocurrency conversions in the same call.

func (*CryptocurrencyService) Map

func (s *CryptocurrencyService) Map(options *MapOptions) ([]*MapListing, error)

Map returns a paginated list of all cryptocurrencies by CoinMarketCap ID.

type Exchange

type Exchange struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
	Slug string `json:"slug"`
}

Exchange ...

type ExchangeQuote

type ExchangeQuote struct {
	Price          float64 `json:"price"`
	Volume24       float64 `json:"volume_24h"`
	Volume24HBase  float64 `json:"volume_24h_base"`  // for 'exchange_reported'
	Volume24HQuote float64 `json:"volume_24h_quote"` // for 'exchange_reported'
	LastUpdated    string  `json:"last_updated"`
}

ExchangeQuote ...

type ExchangeQuotes

type ExchangeQuotes map[string]*ExchangeQuote

ExchangeQuotes ...

type ExchangeReported

type ExchangeReported struct {
	Price          float64 `json:"price"`
	Volume24HBase  float64 `json:"volume_24h_base"`
	Volume24HQuote float64 `json:"volume_24h_quote"`
	LastUpdated    string  `json:"last_updated"`
}

ExchangeReported ...

type ExchangeService

type ExchangeService service

ExchangeService ...

func (*ExchangeService) HistoricalQuotes

func (s *ExchangeService) HistoricalQuotes() error

HistoricalQuotes NOT IMPLEMENTED

func (*ExchangeService) Info

func (s *ExchangeService) Info() error

Info NOT IMPLEMENTED

func (*ExchangeService) LatestListings

func (s *ExchangeService) LatestListings() error

LatestListings NOT IMPLEMENTED

func (*ExchangeService) LatestMarketPairs

func (s *ExchangeService) LatestMarketPairs() error

LatestMarketPairs NOT IMPLEMENTED

func (*ExchangeService) LatestQuotes

func (s *ExchangeService) LatestQuotes() error

LatestQuotes NOT IMPLEMENTED

func (*ExchangeService) Map

func (s *ExchangeService) Map() error

Map NOT IMPLEMENTED

type FiatMapListing

type FiatMapListing struct {
	ID     float64 `json:"id"`
	Name   string  `json:"name"`
	Sign   string  `json:"sign"`
	Symbol string  `json:"symbol"`
}

FiatMapListing is the structure of a fiat map listing

type FiatMapOptions

type FiatMapOptions struct {
	Start         int
	Limit         int
	IncludeMetals bool
}

FiatMapOptions options

type FiatService

type FiatService service

FiatService ...

func (*FiatService) Map

func (s *FiatService) Map(options *FiatMapOptions) ([]*FiatMapListing, error)

Map returns a paginated list of all cryptocurrencies by CoinMarketCap ID.

type GlobalMetricsService

type GlobalMetricsService service

GlobalMetricsService ...

func (*GlobalMetricsService) HistoricalQuotes

func (s *GlobalMetricsService) HistoricalQuotes() error

HistoricalQuotes NOT IMPLEMENTED

func (*GlobalMetricsService) LatestQuotes

func (s *GlobalMetricsService) LatestQuotes(options *QuoteOptions) (*MarketMetrics, error)

LatestQuotes Get the latest quote of aggregate market metrics. Use the "convert" option to return market values in multiple fiat and cryptocurrency conversions in the same call.

type InfoOptions

type InfoOptions struct {
	ID     string
	Symbol string
	Slug   string
}

InfoOptions options

type Listing

type Listing struct {
	ID                float64           `json:"id"`
	Name              string            `json:"name"`
	Symbol            string            `json:"symbol"`
	Slug              string            `json:"slug"`
	CirculatingSupply float64           `json:"circulating_supply"`
	TotalSupply       float64           `json:"total_supply"`
	MaxSupply         float64           `json:"max_supply"`
	DateAdded         string            `json:"date_added"`
	NumMarketPairs    float64           `json:"num_market_pairs"`
	CMCRank           float64           `json:"cmc_rank"`
	LastUpdated       string            `json:"last_updated"`
	Quote             map[string]*Quote `json:"quote"`
}

Listing is the listing structure

type ListingOptions

type ListingOptions struct {
	Start   int
	Limit   int
	Convert string
	Sort    string
}

ListingOptions options

type MapListing

type MapListing struct {
	ID                  float64  `json:"id"`
	Name                string   `json:"name"`
	Symbol              string   `json:"symbol"`
	Slug                string   `json:"slug"`
	IsActive            int      `json:"is_active"`
	FirstHistoricalData string   `json:"first_historical_data"`
	LastHistoricalData  string   `json:"last_historical_data"`
	Platform            Platform `json:"platform"`
}

type MapOptions

type MapOptions struct {
	ListingStatus string
	Start         int
	Limit         int
	Symbol        string
	Sort          string
}

MapOptions options

type MarketMetrics

type MarketMetrics struct {
	BTCDominance           float64                        `json:"btc_dominance"`
	ETHDominance           float64                        `json:"eth_dominance"`
	ActiveCryptocurrencies float64                        `json:"active_cryptocurrencies"`
	ActiveMarketPairs      float64                        `json:"active_market_pairs"`
	ActiveExchanges        float64                        `json:"active_exchanges"`
	LastUpdated            string                         `json:"last_updated"`
	Quote                  map[string]*MarketMetricsQuote `json:"quote"`
}

MarketMetrics is the market metrics structure

type MarketMetricsQuote

type MarketMetricsQuote struct {
	TotalMarketCap float64 `json:"total_market_cap"`
	TotalVolume24H float64 `json:"total_volume_24h"`
	LastUpdated    string  `json:"last_updated"`
}

MarketMetricsQuote is the quote structure

type MarketPair

type MarketPair struct {
	Exchange         *Exchange
	MarketPair       string            `json:"market_pair"`
	MarketPairBase   *MarketPairBase   `json:"market_pair_base"`
	MarketPairQuote  *MarketPairQuote  `json:"market_pair_quote"`
	Quote            ExchangeQuotes    `json:"quote"`
	ExchangeReported *ExchangeReported `json:"exchange_reported"`
}

MarketPair ...

type MarketPairBase

type MarketPairBase struct {
	CurrencyID     int    `json:"currency_id"`
	CurrencySymbol string `json:"currency_symbol"`
	CurrencyType   string `json:"currency_type"`
}

MarketPairBase ...

type MarketPairOptions

type MarketPairOptions struct {
	ID      int
	Symbol  string
	Start   int
	Limit   int
	Convert string
}

MarketPairOptions options

type MarketPairQuote

type MarketPairQuote struct {
	CurrencyID     int    `json:"currency_id"`
	CurrencySymbol string `json:"currency_symbol"`
	CurrencyType   string `json:"currency_type"`
}

MarketPairQuote ...

type MarketPairs

type MarketPairs struct {
	ID             int           `json:"id"`
	Name           string        `json:"name"`
	Symbol         string        `json:"symbol"`
	NumMarketPairs int           `json:"num_market_pairs"`
	MarketPairs    []*MarketPair `json:"market_pairs"`
}

MarketPairs ...

type Platform

type Platform struct {
	ID           int    `json:"id"`
	Name         string `json:"name"`
	Symbol       string `json:"symbol"`
	Slug         string `json:"slug"`
	TokenAddress string `json:"token_address"`
}

MapListing is the structure of a map listing

type Quote

type Quote struct {
	Price            float64 `json:"price"`
	Volume24H        float64 `json:"volume_24h"`
	PercentChange1H  float64 `json:"percent_change_1h"`
	PercentChange24H float64 `json:"percent_change_24h"`
	PercentChange7D  float64 `json:"percent_change_7d"`
	MarketCap        float64 `json:"market_cap"`
	LastUpdated      string  `json:"last_updated"`
}

Quote is the quote structure

type QuoteLatest

type QuoteLatest struct {
	ID                float64           `json:"id"`
	Name              string            `json:"name"`
	Symbol            string            `json:"symbol"`
	Slug              string            `json:"slug"`
	CirculatingSupply float64           `json:"circulating_supply"`
	TotalSupply       float64           `json:"total_supply"`
	MaxSupply         float64           `json:"max_supply"`
	DateAdded         string            `json:"date_added"`
	NumMarketPairs    float64           `json:"num_market_pairs"`
	CMCRank           float64           `json:"cmc_rank"`
	LastUpdated       string            `json:"last_updated"`
	Quote             map[string]*Quote `json:"quote"`
}

QuoteLatest is the quotes structure

type QuoteOptions

type QuoteOptions struct {
	// Covert suppots multiple currencies command separated. eg. "BRL,USD"
	Convert string
	// Symbols suppots multiple tickers command separated. eg. "BTC,ETH,XRP"
	Symbol string
}

QuoteOptions options

type Response

type Response struct {
	Status Status      `json:"status"`
	Data   interface{} `json:"data"`
}

Response is the response structure

type Status

type Status struct {
	Timestamp    string  `json:"timestamp"`
	ErrorCode    int     `json:"error_code"`
	ErrorMessage *string `json:"error_message"`
	Elapsed      int     `json:"elapsed"`
	CreditCount  int     `json:"credit_count"`
}

Status is the status structure

type ToolsService

type ToolsService service

ToolsService ...

func (*ToolsService) PriceConversion

func (s *ToolsService) PriceConversion(options *ConvertOptions) (*ConvertListing, error)

PriceConversion Convert an amount of one currency into multiple cryptocurrencies or fiat currencies at the same time using the latest market averages. Optionally pass a historical timestamp to convert values based on historic averages.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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