Documentation ¶
Index ¶
- type Client
- func (c Client) CoinList(ctx context.Context, opt *CoinListOption) (CoinList, error)
- func (c Client) Coins(ctx context.Context, id string, opt *CoinsOption) (Coins, error)
- func (c *Client) FetchURLToJSON(ctx context.Context, u *url.URL, v interface{}) error
- func (c *Client) GetBytes(ctx context.Context, endpoint string) ([]byte, error)
- func (c *Client) GetFloat64(ctx context.Context, endpoint string) (float64, error)
- func (c *Client) GetJSON(ctx context.Context, endpoint string, v interface{}) error
- func (c *Client) GetJSONWithQueryParams(ctx context.Context, endpoint string, queryParams map[string]string, ...) error
- func (c *Client) GetJSONWithoutToken(ctx context.Context, endpoint string, v interface{}) error
- func (c Client) MarketChart(ctx context.Context, id string, opt *MarketChartOption) (MarketChart, error)
- type ClientOption
- type CoinList
- type CoinListOption
- type Coins
- type CoinsOption
- type Currency
- type Error
- type Interval
- type MarketChart
- type MarketChartOption
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 models a client to consume the Polygon Cloud API.
func NewClient ¶
func NewClient(options ...ClientOption) *Client
NewClient creates a client with the given authorization token.
func (Client) Coins ¶
Coins get current data (name, price, market, ... including exchange tickers) for a coin
func (*Client) FetchURLToJSON ¶
Fetches JSON content from the given URL and unmarshals it into `v`.
func (*Client) GetFloat64 ¶
GetFloat64 gets the number from the given endpoint.
func (*Client) GetJSONWithQueryParams ¶
func (c *Client) GetJSONWithQueryParams(ctx context.Context, endpoint string, queryParams map[string]string, v interface{}) error
GetJSONWithQueryParams gets the JSON data from the given endpoint with the query parameters attached.
func (*Client) GetJSONWithoutToken ¶
GetJSONWithoutToken gets the JSON data from the given endpoint without adding a token to the URL.
func (Client) MarketChart ¶
func (c Client) MarketChart(ctx context.Context, id string, opt *MarketChartOption) (MarketChart, error)
MarketChart Get historical market data include price, market cap, and 24h volume (granularity auto)
type ClientOption ¶
type ClientOption func(*Client)
ClientOption applies an option to the client.
func WithBaseURL ¶
func WithBaseURL(baseURL string) ClientOption
WithBaseURL sets the baseURL for a new IEX Client
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
WithHTTPClient sets the http.Client for a new IEX Client
func WithSecureHTTPClient ¶
func WithSecureHTTPClient() ClientOption
WithSecureHTTPClient sets a secure http.Client for a new IEX Client
type CoinList ¶
type CoinList []struct { ID string `json:"id"` Name string `json:"name"` Symbol string `json:"symbol"` }
CoinList coin list response
type CoinListOption ¶
type CoinListOption struct {
IncludePlatform bool `url:"include_platform,omitempty"`
}
CoinListOption coin list option
type Coins ¶
type Coins struct { Symbol string `json:"symbol"` Name string `json:"name"` Description struct { English string `json:"en"` Japanese string `json:"ja"` } `json:"description,omitempty"` Links struct { HomePage []string `json:"homepage"` } `json:"links"` Image struct { Large string `json:"large"` } `json:"image"` MarketCapRank uint64 `json:"market_cap_rank"` MarketData struct { TotalSupply float64 `json:"total_supply"` MaxSupply float64 `json:"max_supply"` CirculatingSupply float64 `json:"circulating_supply"` } `json:"market_data"` }
Coins coins response
type CoinsOption ¶
type CoinsOption struct { IncludeLocalizedLang bool `url:"localization,omitempty"` IncludeTickersData bool `url:"tickers,omitempty"` IncludeMarketData bool `url:"market_data,omitempty"` IncludeCommunityData bool `url:"community_data,omitempty"` IncludeDeveloperData bool `url:"developer_data,omitempty"` IncludeSparklineData bool `url:"sparkline,omitempty"` }
CoinsOption option for fetching coins
type Currency ¶
type Currency string
Currency curreny
const EUR Currency = "eur"
const JPY Currency = "jpy"
const USD Currency = "usd"
to be added
type Error ¶
type Error struct {
ErrorMessage string `json:"error"`
}
Error represents an Polygon API error
type Interval ¶
type Interval string
Interval used for market chart (only daily supported)
const Daily Interval = "daily"
type MarketChart ¶
type MarketChart struct { MarketCaps [][]float64 `json:"market_caps"` TotalVolumes [][]float64 `json:"total_volumes"` }
MarketChart market chart response
type MarketChartOption ¶
type MarketChartOption struct { TargetCurrency Currency `url:"vs_currency"` Days int `url:"days"` Interval Interval `url:"interval,omitempty"` }
MarketChartOption market chart option