Skip to content

Freespoke/go-votesmart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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