coinmarketcap

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2021 License: MIT Imports: 9 Imported by: 11

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 added in v0.1.1

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 added in v0.1.1

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

ConvertOptions options

type ConvertQuote added in v0.1.1

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 added in v0.1.2

func (s *CryptocurrencyService) HistoricalOHLCV() error

HistoricalOHLCV NOT IMPLEMENTED

func (*CryptocurrencyService) HistoricalQuotes added in v0.1.2

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 added in v0.1.2

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 added in v0.1.1

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

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

type Exchange added in v0.1.2

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

Exchange ...

type ExchangeQuote added in v0.1.2

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 added in v0.1.2

type ExchangeQuotes map[string]*ExchangeQuote

ExchangeQuotes ...

type ExchangeReported added in v0.1.2

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 added in v0.1.2

type ExchangeService service

ExchangeService ...

func (*ExchangeService) HistoricalQuotes added in v0.1.2

func (s *ExchangeService) HistoricalQuotes() error

HistoricalQuotes NOT IMPLEMENTED

func (*ExchangeService) Info added in v0.1.2

func (s *ExchangeService) Info() error

Info NOT IMPLEMENTED

func (*ExchangeService) LatestListings added in v0.1.2

func (s *ExchangeService) LatestListings() error

LatestListings NOT IMPLEMENTED

func (*ExchangeService) LatestMarketPairs added in v0.1.2

func (s *ExchangeService) LatestMarketPairs() error

LatestMarketPairs NOT IMPLEMENTED

func (*ExchangeService) LatestQuotes added in v0.1.2

func (s *ExchangeService) LatestQuotes() error

LatestQuotes NOT IMPLEMENTED

func (*ExchangeService) Map added in v0.1.2

func (s *ExchangeService) Map() error

Map NOT IMPLEMENTED

type FiatMapListing added in v0.1.8

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 added in v0.1.8

type FiatMapOptions struct {
	Start         int
	Limit         int
	IncludeMetals bool
}

FiatMapOptions options

type FiatService added in v0.1.8

type FiatService service

FiatService ...

func (*FiatService) Map added in v0.1.8

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

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

type GlobalMetricsService added in v0.1.2

type GlobalMetricsService service

GlobalMetricsService ...

func (*GlobalMetricsService) HistoricalQuotes added in v0.1.2

func (s *GlobalMetricsService) HistoricalQuotes() error

HistoricalQuotes NOT IMPLEMENTED

func (*GlobalMetricsService) LatestQuotes added in v0.1.2

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 added in v0.1.1

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 added in v0.1.1

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

MapOptions options

type MarketMetrics added in v0.1.2

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 added in v0.1.2

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 added in v0.1.2

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 added in v0.1.2

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

MarketPairBase ...

type MarketPairOptions added in v0.1.2

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

MarketPairOptions options

type MarketPairQuote added in v0.1.2

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

MarketPairQuote ...

type MarketPairs added in v0.1.2

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 added in v0.1.8

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 added in v0.1.1

type ToolsService service

ToolsService ...

func (*ToolsService) PriceConversion added in v0.1.1

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