smithsonian

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: 10 Imported by: 0

Documentation

Overview

Package smithsonian is the library behind the smithsonian command line: the HTTP client, request shaping, and typed data models for the Smithsonian Open Access API (https://api.si.edu/openaccess/api/v1.0).

The demo API key (DEMO_KEY) works without registration. The Client paces requests, sets a real User-Agent, and retries transient failures (429 and 5xx).

Index

Constants

View Source
const Host = "api.si.edu"

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 Smithsonian Open Access API.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client with the given configuration.

func (*Client) Search

func (c *Client) Search(ctx context.Context, query string, rows, start int) ([]Object, error)

Search searches museum objects matching query.

func (*Client) Stats

func (c *Client) Stats(ctx context.Context) ([]UnitStat, error)

Stats returns object counts per Smithsonian unit.

type Config

type Config struct {
	BaseURL   string
	APIKey    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 smithsonian driver.

func (Domain) Classify

func (Domain) Classify(input string) (string, string, error)

Classify turns any string into (type, id).

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, hostnames, and binary identity.

func (Domain) Locate

func (Domain) Locate(t, 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.

type Object

type Object struct {
	ID         string `kit:"id" json:"id"`
	Title      string `json:"title"`
	UnitCode   string `json:"unit_code"`
	DataSource string `json:"data_source"`
	Type       string `json:"type"`
	RecordLink string `json:"record_link,omitempty"`
	Access     string `json:"access,omitempty"`
}

Object holds the public data about a single Smithsonian museum object.

type UnitStat

type UnitStat struct {
	Unit       string `kit:"id" json:"unit"`
	DataSource string `json:"data_source"`
	Total      int    `json:"total_objects"`
	CC0        int    `json:"cc0_records"`
}

UnitStat holds object counts for a single Smithsonian unit.

Jump to

Keyboard shortcuts

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