Documentation
¶
Overview ¶
Package alternativeme is the library behind the alternativeme command line: the HTTP client, request shaping, and the typed data models for the Alternative.me Crypto Fear & Greed Index.
The Client sets a real User-Agent, paces requests to stay polite, and retries transient failures (429 and 5xx). Build your endpoint calls and JSON decoding on top of it.
Index ¶
Constants ¶
const BaseURL = "https://api.alternative.me"
BaseURL is the root every request is built from.
const Host = "api.alternative.me"
Host is the API hostname.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client talks to alternative.me over HTTP.
func NewClientFromConfig ¶
NewClientFromConfig builds a Client from the given Config.
func (*Client) GetFearGreed ¶
GetFearGreed fetches limit days of the Crypto Fear & Greed Index. Limit 1 returns today's reading only. The timestamp is converted from a Unix second string to "2006-01-02" format; value is converted from a JSON string ("18") to int.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Retries int
Timeout time.Duration
}
Config holds all tunables for a Client.
type Domain ¶
type Domain struct{}
Domain is the alternativeme driver. It carries no state; the per-run client is built by the factory Register hands kit.
func (Domain) Classify ¶
Classify turns any accepted input into (uriType, id). "feargreed" or "index" maps to ("index", "feargreed"). A bare date like "2024-01-01" maps to ("date", "2024-01-01").
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme and identity for both the binary and the URI driver.
type FearGreedRecord ¶
type FearGreedRecord struct {
Timestamp string `json:"timestamp" kit:"id"`
Value int `json:"value"`
Classification string `json:"classification"`
}
FearGreedRecord is one day's Fear & Greed reading.