Documentation
¶
Overview ¶
Package metmuseum is the library behind the metmuseum command line: the HTTP client, request shaping, and typed data models for the Metropolitan Museum of Art public Collection API (https://collectionapi.metmuseum.org/public/collection/v1).
No API key is required. The Client paces requests, sets a real User-Agent, and retries transient failures (429 and 5xx).
Index ¶
Constants ¶
const BaseURL = "https://" + Host + "/public/collection/v1"
BaseURL is the root every API request is built from.
const DefaultUserAgent = "metmuseum-cli/0.1.0 (github.com/tamnd/metmuseum-cli)"
DefaultUserAgent identifies the client to the Met Museum API.
const Host = "collectionapi.metmuseum.org"
Host is the API hostname.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the Metropolitan Museum of Art API.
func (*Client) ListDepartments ¶
func (c *Client) ListDepartments(ctx context.Context) ([]Department, error)
ListDepartments lists all museum departments.
func (*Client) SearchObjects ¶
func (c *Client) SearchObjects(ctx context.Context, q string, hasImages, publicDomain bool, deptID, limit int) ([]Object, error)
SearchObjects searches objects and fetches full details for the top results. It calls /search first, then fans out to /objects/{id} for each ID up to limit.
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 Department ¶
Department holds museum department data.
type Domain ¶
type Domain struct{}
Domain is the metmuseum driver.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, hostnames, and binary identity.
type Object ¶
type Object struct {
ID int `json:"id"`
Title string `json:"title"`
Artist string `json:"artist"`
Nationality string `json:"nationality,omitempty"`
Date string `json:"date,omitempty"`
Medium string `json:"medium,omitempty"`
Dimensions string `json:"dimensions,omitempty"`
Department string `json:"department,omitempty"`
PublicDomain bool `json:"public_domain"`
PrimaryImageSmall string `json:"primary_image_small,omitempty"`
URL string `json:"url,omitempty"`
}
Object holds the public data about a single museum object.
type SearchResult ¶
SearchResult holds raw search results (IDs only).