fec

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

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

View Source
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

type CandidateFilter struct {
	State  string
	Party  string
	Office string
	Limit  int
}

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

func NewClientWithConfig(cfg Config) *Client

NewClientWithConfig returns a Client configured from cfg.

func (*Client) Candidate

func (c *Client) Candidate(ctx context.Context, id string) (*Candidate, error)

Candidate fetches a single candidate by ID.

func (*Client) Candidates

func (c *Client) Candidates(ctx context.Context, f CandidateFilter) ([]*Candidate, error)

Candidates returns a list of candidates matching the optional filters.

func (*Client) Committee

func (c *Client) Committee(ctx context.Context, id string) (*Committee, error)

Committee fetches a single committee by ID.

func (*Client) Committees

func (c *Client) Committees(ctx context.Context, f CommitteeFilter) ([]*Committee, error)

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

type CommitteeFilter struct {
	Type  string
	State string
	Limit int
}

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) Classify

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

Classify turns any accepted input into the canonical (type, id).

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.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate is the inverse: 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.

Jump to

Keyboard shortcuts

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