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
- type Bill
- type BillDetail
- type BillsOptions
- type Client
- func (c *Client) Bill(ctx context.Context, congress int, billType, number string) (*BillDetail, error)
- func (c *Client) Bills(ctx context.Context, opts BillsOptions) ([]*Bill, *Pagination, error)
- func (c *Client) Committees(ctx context.Context, opts CommitteesOptions) ([]*Committee, *Pagination, error)
- func (c *Client) Member(ctx context.Context, bioguideID string) (*MemberDetail, error)
- func (c *Client) Members(ctx context.Context, opts MembersOptions) ([]*Member, *Pagination, error)
- type Committee
- type CommitteesOptions
- type Config
- type Depiction
- type Domain
- type LatestAction
- type Member
- type MemberDetail
- type MembersOptions
- type Pagination
- type Sponsor
Constants ¶
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 (*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) 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 ¶
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) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames, and the binary identity.
type LatestAction ¶
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.