Documentation
¶
Overview ¶
Package govinfo is the library behind the govinfo command line: the HTTP client, request shaping, and the typed data models for the US Government Publishing Office GovInfo API (api.govinfo.gov).
The GovInfo API is open for public data with DEMO_KEY: no signup required. This package wraps the REST API with a rate-limited client that the kit operations consume.
Index ¶
Constants ¶
const DefaultUserAgent = "govinfo-cli/0.1 (tamnd87@gmail.com)"
DefaultUserAgent identifies the client to the GovInfo API honestly.
const Host = "api.govinfo.gov"
Host is the canonical site hostname used in URI routing.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a rate-limited HTTP client for the GovInfo REST API.
func (*Client) GetPackage ¶
GetPackage fetches the summary for a single package by ID.
func (*Client) ListCollections ¶
func (c *Client) ListCollections(ctx context.Context) ([]Collection, error)
ListCollections fetches all document collections from GovInfo.
func (*Client) ListPackages ¶
func (c *Client) ListPackages(ctx context.Context, collection, since string, size, page int) ([]Package, error)
ListPackages fetches packages from a collection since a given date. collection: e.g. "BILLS" since: RFC3339 or date string, e.g. "2020-01-01T00:00:00Z" size: page size (default 25) page: 1-based page number (maps to offsetMark via cursor, simplified here)
type Collection ¶
type Collection struct {
Code string `json:"code"`
Name string `json:"name"`
PackageCount int `json:"packageCount"`
}
Collection is a document collection available in GovInfo.
type Config ¶
type Config struct {
BaseURL string
APIKey string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds constructor parameters for Client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns sensible defaults for api.govinfo.gov.
type Domain ¶
type Domain struct{}
Domain is the GovInfo 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 and the identity the single-site binary inherits.
type Package ¶
type Package struct {
PackageID string `json:"packageId" kit:"id"`
Congress string `json:"congress"`
DocClass string `json:"docClass"`
Title string `json:"title"`
DateIssued string `json:"dateIssued"`
LastModified string `json:"lastModified"`
}
Package is a document package within a collection.
type PackageSummary ¶
type PackageSummary struct {
PackageID string `json:"packageId" kit:"id"`
Title string `json:"title"`
DocClass string `json:"docClass"`
Congress string `json:"congress"`
Session string `json:"session"`
DateIssued string `json:"dateIssued"`
LastModified string `json:"lastModified"`
DownloadURL string `json:"downloadURL"`
}
PackageSummary is the detailed metadata for a single package.