congress

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package congress is the library behind the congress command line: the HTTP client, request shaping, and typed data models for the Congress.gov API.

The Client sets a real User-Agent, paces requests to stay polite, and retries transient failures (429 and 5xx). All endpoint calls append api_key and format=json automatically via the get() helper.

Index

Constants

View Source
const Host = "api.congress.gov"

Host is the canonical hostname for Congress.gov URI construction.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bill

type Bill struct {
	Congress     int          `json:"congress"`
	Type         string       `json:"type"`
	Number       string       `json:"number"`
	Title        string       `json:"title"`
	LatestAction LatestAction `json:"latestAction"`
	URL          string       `json:"url"`
}

Bill represents a legislative bill from Congress.gov.

type BillDetail

type BillDetail struct {
	Congress     int          `json:"congress"`
	Type         string       `json:"type"`
	Number       string       `json:"number"`
	Title        string       `json:"title"`
	LatestAction LatestAction `json:"latestAction"`
	URL          string       `json:"url,omitempty"`
	// Extended fields
	Sponsors   []Sponsor `json:"sponsors,omitempty"`
	PolicyArea *struct {
		Name string `json:"name"`
	} `json:"policyArea,omitempty"`
	Introduced        string `json:"introducedDate,omitempty"`
	OriginChamber     string `json:"originChamber,omitempty"`
	OriginChamberCode string `json:"originChamberCode,omitempty"`
	UpdateDate        string `json:"updateDate,omitempty"`
}

BillDetail holds extended bill information returned by the single-bill endpoint.

type BillsOptions

type BillsOptions struct {
	Limit    int
	Offset   int
	Congress int    // 0 = all congresses
	Type     string // hr, s, hjres, sjres, etc.
}

BillsOptions controls the /bill list call.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to the Congress.gov API over HTTPS.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client using cfg.

func (*Client) Bill

func (c *Client) Bill(ctx context.Context, congress int, billType, number string) (*BillDetail, error)

Bill fetches a single bill by congress/type/number.

func (*Client) Bills

func (c *Client) Bills(ctx context.Context, opts BillsOptions) ([]*Bill, *Pagination, error)

Bills lists legislative bills.

func (*Client) Committees

func (c *Client) Committees(ctx context.Context, opts CommitteesOptions) ([]*Committee, *Pagination, error)

Committees lists congressional committees.

func (*Client) Member

func (c *Client) Member(ctx context.Context, bioguideID string) (*MemberDetail, error)

Member fetches a single member by bioguide ID.

func (*Client) Members

func (c *Client) Members(ctx context.Context, opts MembersOptions) ([]*Member, *Pagination, error)

Members lists members of Congress.

type Committee

type Committee struct {
	SystemCode        string `json:"systemCode"`
	Name              string `json:"name"`
	Chamber           string `json:"chamber"`
	CommitteeTypeCode string `json:"committeeTypeCode"`
	URL               string `json:"url,omitempty"`
}

Committee represents a congressional committee.

type CommitteesOptions

type CommitteesOptions struct {
	Limit   int
	Offset  int
	Chamber string // senate, house, joint
}

CommitteesOptions controls the /committee list call.

type Config

type Config struct {
	BaseURL   string
	UserAgent string
	APIKey    string
	Rate      time.Duration
	Timeout   time.Duration
	Retries   int
}

Config holds the client configuration.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults.

type Depiction

type Depiction struct {
	ImageURL  string `json:"imageUrl"`
	Copyright string `json:"copyright,omitempty"`
}

Depiction holds a member's image information.

type Domain

type Domain struct{}

Domain is the congress driver.

func (Domain) Classify

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

Classify turns a Congress.gov URL or bare path into (type, id).

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the hostnames, and the binary identity.

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.

type LatestAction

type LatestAction struct {
	ActionDate string `json:"actionDate"`
	Text       string `json:"text"`
}

LatestAction describes the most recent legislative action on a bill.

type Member

type Member struct {
	BioguideID string    `json:"bioguideId"`
	Name       string    `json:"name"`
	State      string    `json:"state"`
	PartyName  string    `json:"partyName"`
	District   int       `json:"district,omitempty"`
	Depiction  Depiction `json:"depiction,omitempty"`
	URL        string    `json:"url,omitempty"`
}

Member represents a member of Congress.

type MemberDetail

type MemberDetail struct {
	BioguideID      string    `json:"bioguideId"`
	FirstName       string    `json:"firstName"`
	LastName        string    `json:"lastName"`
	DirectOrderName string    `json:"directOrderName,omitempty"`
	State           string    `json:"state"`
	PartyName       string    `json:"partyName"`
	District        int       `json:"district,omitempty"`
	Depiction       Depiction `json:"depiction,omitempty"`
	BirthYear       string    `json:"birthYear,omitempty"`
	CurrentMember   bool      `json:"currentMember,omitempty"`
	Leadership      []struct {
		Type string `json:"type"`
	} `json:"leadership,omitempty"`
}

MemberDetail holds extended member information.

type MembersOptions

type MembersOptions struct {
	Limit  int
	Offset int
	State  string // two-letter state code
	Party  string // D, R, ID, etc.
}

MembersOptions controls the /member list call.

type Pagination

type Pagination struct {
	Count int    `json:"count"`
	Next  string `json:"next,omitempty"`
	Prev  string `json:"prev,omitempty"`
}

Pagination holds paging metadata from list responses.

type Sponsor struct {
	BioguideID string `json:"bioguideId"`
	FirstName  string `json:"firstName"`
	LastName   string `json:"lastName"`
	Party      string `json:"party"`
	State      string `json:"state"`
}

Sponsor is a bill sponsor reference.

Jump to

Keyboard shortcuts

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