Documentation
¶
Overview ¶
Package artic is the library behind the artic command line: the HTTP client, request shaping, and typed data models for the Art Institute of Chicago public API (https://api.artic.edu/api/v1).
No API key is required. The Client paces requests, sets a real User-Agent, and retries transient failures (429 and 5xx).
Index ¶
- Constants
- type Artwork
- type Client
- func (c *Client) Get(ctx context.Context, rawURL string) ([]byte, error)
- func (c *Client) GetArtwork(ctx context.Context, id string) (*Artwork, error)
- func (c *Client) ListArtworks(ctx context.Context, limit, page int) ([]*Artwork, int, error)
- func (c *Client) SearchArtworks(ctx context.Context, query string, limit, page int) ([]*Artwork, int, error)
- type Config
- type Domain
Constants ¶
const DefaultUserAgent = "artic-cli/0.1.0 (github.com/tamnd/artic-cli)"
DefaultUserAgent identifies the client to the Art Institute API.
const Host = "api.artic.edu"
Host is the API hostname this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Artwork ¶
type Artwork struct {
ID string `json:"id" kit:"id"` // string-formatted integer ID
Title string `json:"title"`
Artist string `json:"artist,omitempty"`
Date string `json:"date,omitempty"`
Medium string `json:"medium,omitempty"`
Dimensions string `json:"dimensions,omitempty"`
Type string `json:"type,omitempty"`
Department string `json:"department,omitempty"`
Subjects []string `json:"subjects,omitempty"`
ImageURL string `json:"image_url,omitempty"` // computed from image_id
}
Artwork is a single record from the Art Institute of Chicago collection.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the Art Institute of Chicago API.
func NewClientWithConfig ¶
NewClientWithConfig returns a Client using the provided Config.
func (*Client) Get ¶
Get fetches url and returns the response body. It paces and retries according to the client's settings.
func (*Client) GetArtwork ¶
GetArtwork fetches a single artwork by its string ID.
func (*Client) ListArtworks ¶
ListArtworks lists artworks from the collection in publication order. page is 1-based. Returns (artworks, total, error).
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tunable parameters for the Client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults.
type Domain ¶
type Domain struct{}
Domain is the artic driver. It carries no state; the per-run client is built by the factory Register hands kit.
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.