Documentation
¶
Overview ¶
Package fec is the library behind the fec command line: the HTTP client, request shaping, and the typed data models for the FEC Open Data API (api.open.fec.gov/v1).
The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, appends the required api_key param, and retries the transient failures (429 and 5xx) that any public API throws under load.
Index ¶
- Constants
- type Candidate
- type CandidateFilter
- type Client
- func (c *Client) Candidate(ctx context.Context, id string) (*Candidate, error)
- func (c *Client) Candidates(ctx context.Context, f CandidateFilter) ([]*Candidate, error)
- func (c *Client) Committee(ctx context.Context, id string) (*Committee, error)
- func (c *Client) Committees(ctx context.Context, f CommitteeFilter) ([]*Committee, error)
- type Committee
- type CommitteeFilter
- type Config
- type Domain
Constants ¶
const Host = "api.open.fec.gov"
Host is the domain this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Candidate ¶
type Candidate struct {
ID string `json:"candidate_id" kit:"id"`
Name string `json:"name" kit:"body"`
Party string `json:"party_full,omitempty"`
Office string `json:"office_full,omitempty"`
State string `json:"state,omitempty"`
District string `json:"district,omitempty"`
Incumbent string `json:"incumbent_challenge_full,omitempty"`
FirstFileDate string `json:"first_file_date,omitempty"`
ActiveThrough int `json:"active_through,omitempty"`
}
Candidate is a single FEC candidate record.
type CandidateFilter ¶
CandidateFilter holds the optional filters for listing candidates.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the FEC Open Data API over HTTP.
func NewClient ¶
func NewClient() *Client
NewClient returns a Client with the default configuration.
func NewClientWithConfig ¶
NewClientWithConfig returns a Client configured from cfg.
func (*Client) Candidates ¶
Candidates returns a list of candidates matching the optional filters.
func (*Client) Committees ¶
Committees returns a list of committees matching the optional filters.
type Committee ¶
type Committee struct {
ID string `json:"committee_id" kit:"id"`
Name string `json:"name" kit:"body"`
Type string `json:"committee_type_full,omitempty"`
Party string `json:"party_full,omitempty"`
State string `json:"state,omitempty"`
Treasurer string `json:"treasurer_name,omitempty"`
FilingFreq string `json:"filing_frequency,omitempty"`
FirstFileDate string `json:"first_file_date,omitempty"`
}
Committee is a single FEC committee record.
type CommitteeFilter ¶
CommitteeFilter holds the optional filters for listing committees.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
APIKey string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all runtime knobs for the client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns sensible defaults for the FEC Open Data API.
type Domain ¶
type Domain struct{}
Domain is the fec driver. It carries no state; the per-run client is built by the factory Register hands to kit.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.