Documentation
¶
Overview ¶
Package coinbase is the library behind the coinbase command line: the HTTP client, request shaping, and the typed data models for the Coinbase public v2 API (api.coinbase.com/v2). No API key is required for the read-only endpoints this package uses.
Index ¶
- Constants
- type Client
- func (c *Client) Buy(ctx context.Context, pair string) (*Price, error)
- func (c *Client) CryptoCurrencies(ctx context.Context) ([]Currency, error)
- func (c *Client) Currencies(ctx context.Context) ([]Currency, error)
- func (c *Client) Get(ctx context.Context, url string) ([]byte, error)
- func (c *Client) Rates(ctx context.Context, currency string) ([]Rate, error)
- func (c *Client) Spot(ctx context.Context, pair string) (*Price, error)
- type Config
- type Currency
- type Domain
- type Price
- type Rate
Constants ¶
const BaseURL = "https://api.coinbase.com/v2"
BaseURL is the Coinbase v2 API base.
const DefaultUserAgent = "coinbase-cli/dev (+https://github.com/tamnd/coinbase-cli)"
DefaultUserAgent identifies the client to Coinbase.
const Host = "api.coinbase.com"
Host is the Coinbase API host (used by the URI driver).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
HTTP *http.Client
UserAgent string
Rate time.Duration
Retries int
// contains filtered or unexported fields
}
Client talks to the Coinbase public v2 API over HTTPS.
func (*Client) Buy ¶ added in v0.1.1
Buy returns the buy price for a currency pair such as "BTC-USD".
func (*Client) CryptoCurrencies ¶ added in v0.1.2
CryptoCurrencies returns all supported crypto currencies from /v2/currencies/crypto. The endpoint uses a different wire shape (code/name, no min_size) so we map it to the shared Currency type.
func (*Client) Currencies ¶
Currencies returns all supported fiat currencies from /v2/currencies.
func (*Client) Get ¶
Get fetches url and returns the response body, pacing and retrying as configured.
type Currency ¶
type Currency struct {
ID string `kit:"id" json:"id"`
Name string `json:"name"`
MinSize string `json:"min_size"`
}
Currency is one entry from /v2/currencies.
type Domain ¶
type Domain struct{}
Domain is the coinbase driver.
func (Domain) Classify ¶
Classify turns any accepted input into the canonical (type, id). A pair like "BTC-USD" maps to ("pair", "BTC-USD"); a bare currency like "BTC" maps to ("currency", "BTC").
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.