Documentation
¶
Overview ¶
Package govtrack is the library behind the govtrack command line: the HTTP client, request shaping, and typed data models for the GovTrack.us API v2 (https://www.govtrack.us/api/v2).
The API requires no key. The Client paces requests, sets a real User-Agent, and retries transient failures (429 and 5xx).
Index ¶
- Constants
- type Bill
- type Client
- func (c *Client) GetBill(ctx context.Context, id int) (*Bill, error)
- func (c *Client) ListBills(ctx context.Context, congress, limit int) ([]Bill, error)
- func (c *Client) ListPeople(ctx context.Context, role string, limit int) ([]Person, error)
- func (c *Client) ListVotes(ctx context.Context, congress, limit int) ([]Vote, error)
- func (c *Client) SearchBills(ctx context.Context, query string, limit int) ([]Bill, error)
- type Config
- type Domain
- type Person
- type Vote
Constants ¶
const BaseURL = "https://" + Host + "/api/v2"
BaseURL is the root every API request is built from.
const Host = "www.govtrack.us"
Host is the API hostname.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bill ¶
type Bill struct {
ID int `json:"id" kit:"id"`
Congress int `json:"congress"`
Type string `json:"type"`
Number int `json:"number"`
Title string `json:"title"`
IntroducedDate string `json:"introducedDate,omitempty"`
Status string `json:"status,omitempty"`
URL string `json:"url"`
}
Bill holds flattened bill metadata from GovTrack.us.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to GovTrack.us API over HTTP.
func (*Client) ListPeople ¶
ListPeople returns congress members filtered by role type. role: "senator", "representative", or "" for all.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tunable parameters for the Client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults for GovTrack.us.
type Domain ¶
type Domain struct{}
Domain is the govtrack driver for the kit framework.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, hostnames, and binary identity.
type Person ¶
type Person struct {
ID int `json:"id" kit:"id"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Party string `json:"party,omitempty"`
State string `json:"state,omitempty"`
Role string `json:"role,omitempty"`
URL string `json:"url"`
}
Person holds a congress member's metadata from GovTrack.us.
type Vote ¶
type Vote struct {
ID int `json:"id" kit:"id"`
Congress int `json:"congress"`
Question string `json:"question"`
Result string `json:"result"`
Created string `json:"created,omitempty"`
Chamber string `json:"chamber,omitempty"`
URL string `json:"url"`
}
Vote holds flattened vote metadata from GovTrack.us.