knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of opensecrets is to create a reimagining of the OpenSecrets API. The package is intended to follow almost verbatim with the API documentation. Refer to the documentation for more information of the data that is retrieved.
You can install the released version of opensecrets from GitHub with:
remotes::install_github("josiahparry/opensecrets")
This package is in very experimental phases and is subject to breaking. There is much to do, but a this serves as a minimal viable product.
Please submit issues and feature requests as you come about them.
Register with OpenSecrets and register for an API key at this link.
Set your key using set_os_key("my_key_here")
or store it in .Renviron
List all available legislators for a given state.
library(opensecrets) ca_legislators <- get_legislators("CA") ca_legislators
Get personal finance information for a given legislator.
library(tidyverse) # get Nancy Pelosi ca_legislators %>% filter(firstlast == "Nancy Pelosi") %>% pull(cid) %>% personal_finance()
Use purrr::map()
to iterate over multiple individuals.
ca_legislators %>% # take only 3 legislators slice(1:3) %>% mutate(pf = map(cid, personal_finance)) %>% unnest()
opensecrets::legislators
opensecrets::categories
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.