artic

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

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

View Source
const DefaultUserAgent = "artic-cli/0.1.0 (github.com/tamnd/artic-cli)"

DefaultUserAgent identifies the client to the Art Institute API.

View Source
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 NewClient

func NewClient() *Client

NewClient returns a Client with sensible defaults.

func NewClientWithConfig

func NewClientWithConfig(cfg Config) *Client

NewClientWithConfig returns a Client using the provided Config.

func (*Client) Get

func (c *Client) Get(ctx context.Context, rawURL string) ([]byte, error)

Get fetches url and returns the response body. It paces and retries according to the client's settings.

func (*Client) GetArtwork

func (c *Client) GetArtwork(ctx context.Context, id string) (*Artwork, error)

GetArtwork fetches a single artwork by its string ID.

func (*Client) ListArtworks

func (c *Client) ListArtworks(ctx context.Context, limit, page int) ([]*Artwork, int, error)

ListArtworks lists artworks from the collection in publication order. page is 1-based. Returns (artworks, total, error).

func (*Client) SearchArtworks

func (c *Client) SearchArtworks(ctx context.Context, query string, limit, page int) ([]*Artwork, int, error)

SearchArtworks searches artworks by query, returning up to limit results from page. 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) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify turns any accepted input into the canonical (type, id).

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.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate returns the live https URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL