Documentation
¶
Overview ¶
Package cryptoprice provides a simple Client for querying the most accurate crypto currency price available from the CryptoCompare REST API.
This is not intended to be a complete implementation of the full CryptoCompare REST API. It just accesses the CryptoCompare REST API endpoints required to get the most accurate price available for a given time.
The CryptoCompare REST API documentation can be found here: https://min-api.cryptocompare.com/
Index ¶
Constants ¶
const ( CryptoCompareURL = "https://min-api.cryptocompare.com/data" NowURI = "/price" MinuteURI = "/histominute" HourURI = "/histohour" DefaultExtraParams = "golang pkg - github.com/canonical-ledgers/cryptoprice" )
Default URIs and parameters
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
URL string
// Get price of Currency in Units.
Currency string
Units string
// Only return data for direct trading pairs. Do not perform conversions.
DirectPairOnly bool
// Exchange to use for data (default: "CCCAGG" aggregated average)
Exchange string
// ExtraParams should be the name of your application, defaults to
// const DefaultExtraParams
ExtraParams string
APIKey string
http.Client
}
Client stores request parameters and provides methods for querying the CryptoCompare REST API. You may set any additional http.Client settings directly on this type.
func NewClient ¶
NewClient returns a pointer to a new Client with the given Currency and Units set, as well as the correct CryptoCompare API endpoint URL.
func (*Client) GetPriceAt ¶
GetPriceAt returns the most accurate price available for the given time t. If the requested time is within the past minute, the most recent price data is used. If the requested time is within the past 7 days, the simple average of the high and low prices for the minute that is closest to the given time is used. If the request time is any further in the past, the simple average of the high and low prices for the hour that is closest to the given price is used.