Documentation
¶
Overview ¶
Package coincap is a simple coincap.io API wrapper library. Note, that in many structs json.Number is used instead of string or float64. This is because for some unknown reason coincap may send same fields as numbers or as strings.
Index ¶
- Constants
- type Client
- func (c *Client) Coins() ([]string, error)
- func (c *Client) CoinsXCP() ([]string, error)
- func (c *Client) CoinsXCPAll() ([]string, error)
- func (c *Client) Front() ([]Front, error)
- func (c *Client) FrontXCP() ([]Front, error)
- func (c *Client) Global() (Global, error)
- func (c *Client) History(symb, interval string) (*History, error)
- func (c *Client) Map() ([]Mapping, error)
- func (c *Client) Page(symb string) (*Page, error)
- func (c *Client) SubscribeTrades(dataChan chan<- *Trade, stopChan <-chan bool) error
- type Front
- type Global
- type History
- type Mapping
- type Page
- type Trade
- type TradeData
- type TradeMessage
Constants ¶
const ( HistoryIntervalAll = "" HistoryInterval1Day = "1day" HistoryInterval7Days = "7day" HistoryInterval30Days = "30day" HistoryInterval90Days = "90day" HistoryInterval180Days = "180day" HistoryInterval365Days = "365day" )
HistoryInterval* consts are used in History() request.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client send API requests and parses responses. It also can be used for subscription on websocket.
func (*Client) CoinsXCPAll ¶
CoinsXCPAll requests coins/xcp/all path.
func (*Client) History ¶
History requests /history path for given symbol.
interval can be either empty (returns all history on a coin), or one of the HistoryInterval* consts.
func (*Client) SubscribeTrades ¶
SubscribeTrades subscribes for websocket messages on 'trades' channel. All incoming messages are sent to 'dataChan'. If there are errors during subscription, it returns an error immediately. Otherwise, it blocks, waiting for an error, or stop signal. If an error occures, it will be returned as the result.
dataChan - a channel for Trade messages. stopChan - a channel to cancel or reset ws subscribtion. close it or send 'true' to stop subscribtion. send 'false' to reconnect. May be useful, if updates stalled.
type Front ¶
type Front struct {
Long string
Short string
Shapeshift bool
Price json.Number
Cap24hrChange json.Number
Mktcap json.Number
Perc json.Number
Supply json.Number
USDVolume json.Number
Volume json.Number
VwapData *json.Number
VwapDataBTC *json.Number
}
Front is a reply for /front path.
type Global ¶
type Global struct {
BTCPrice json.Number
BTCCap json.Number
AltCap json.Number
Dom json.Number
BitnodesCount json.Number
TotalCap json.Number
VolumeAlt json.Number
VolumeBtc json.Number
VolumeTotal json.Number
}
Global is a websocket message from 'global' channel, and a reply for /global path.
type History ¶
type History struct {
Price [][2]json.Number
MarketCap [][2]json.Number `json:"market_cap"`
Volume [][2]json.Number
}
History is a reply for /history path.
type Page ¶
type Page struct {
Global
ID string
Type string
IDD string `json:"_id"`
DisplayName string `json:"display_name"`
Status string
PriceUSD json.Number `json:"price_usd"`
PriceEUR json.Number `json:"price_eur"`
PriceBTC json.Number `json:"price_btc"`
PriceETH json.Number `json:"price_eth"`
PriceZEC json.Number `json:"price_zec"`
PriceLTC json.Number `json:"price_ltc"`
MarketCap json.Number `json:"market_cap"`
Cap24hChange json.Number `json:"cap24hrChange"`
Supply json.Number
Volume json.Number
Price json.Number
VWAP24h json.Number `json:"vwap_h24"`
}
Page is a reply for /page path.
type Trade ¶
type Trade struct {
Msg TradeMessage
Data TradeData
}
Trade contains trade message and an optional trade data.
type TradeData ¶
type TradeData struct {
ExchangeID string `json:"exchange_id"`
MarketID string `json:"market_id"`
Price json.Number
Raw struct {
ID string
TimeStamp time.Time
Quantity json.Number
Price json.Number
Total json.Number
FillType string
OrderType string
}
TimestampMs int64 `json:"timestamp_ms"`
Volume json.Number
}
TradeData is a piece of information about a trade.