Skip to content

Latest commit

 

History

History
47 lines (33 loc) · 1.14 KB

README.md

File metadata and controls

47 lines (33 loc) · 1.14 KB

go-votesmart

A golang client for the Votesmart API.

Go Reference Actions Status

Installation

$ go get dev.freespoke.com/go-votesmart

Usage

Create an API client instance using your API Key.

client, err := votesmart.New(os.Getenv("VOTESMART_API_KEY"))
if err != nil {
    t.Fatal(err)
}

Make requests by providing a VoteSmart response object, and a *url.Values containing desired URL params:

var resp votesmarttypes.CandidatesGetByLastname
vals := url.Values{}
vals.Add("lastName", "desantis")
vals.Add("electionYear", "2022")

if err := client.Invoke(context.Background(), &vals, &resp); err != nil {
    log.Fatal(err)
}

log.Println(resp)

Refer to the API Documentation for required and optional parameters. Do not set o or key, as the library handles these for you.

License

MIT