-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
108 lines (77 loc) · 3.79 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = '#>',
fig.path = 'man/figures/README-',
out.width = '100%'
)
```
# congress <img src="man/figures/logo.png" align="right" height="130" />
<!-- badges: start -->
[](https://CRAN.R-project.org/package=congress)
[](https://christopherkenny.r-universe.dev/congress)
[](https://lifecycle.r-lib.org/articles/stages.html#stable)
[](https://github.com/christopherkenny/congress/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/christopherkenny/congress?branch=main)
<!-- badges: end -->
`congress` provides a *mostly* tidy interface to the Congress.gov API, available at <https://github.com/LibraryOfCongress/api.congress.gov/>.
It provides a simple R interface for downloading and working with actions, bills, nominations, and more from Congress.
## Installation
You can install the stable version of `congress` from [CRAN](https://CRAN.R-project.org/package=congress) with:
``` r
install.packages('congress')
```
You can install the development version of congress from [GitHub](https://github.com/) with:
``` r
# install.packages('devtools')
devtools::install_github('christopherkenny/congress')
```
## Example
To get the most recent `nomination`s, we can use the `cong_nomination()` function. By default, it gets the most recent 20. We request here, the most recent 10.
```{r example}
library(congress)
cong_nomination(limit = 10)
```
You can request up to 250 results, using `limit`. Once a request has been made, you can request the next set by using the `offset` argument:
```{r}
cong_nomination(limit = 10, offset = 10)
```
You can also request the next set using the `cong_request_next()` function:
```{r}
cong_nomination(limit = 10) |>
cong_request_next()
```
## Supported Endpoints:
This package is designed for `v3` of the [Congress.gov API](https://github.com/LibraryOfCongress/api.congress.gov/). It currently supports the following endpoints:
- bills with `cong_bill()`
- amendments with `cong_amendment()`
- summaries with `cong_summaries()`
- congresses with `cong_congress()`
- members with `cong_member()`
- committees with `cong_committee()`
- committee reports with `cong_committee_report()`
- committee prints with `cong_committee_print()`
- committee meetings with `cong_committee_meeting()`
- Congressional Records with `cong_record()`
- Daily Congressional Records with `cong_daily_record()`
- Bound Congressional Records with `cong_bound_record()`
- House communications with `cong_house_communication()`
- Senate communications with `cong_senate_communication()`
- nominations with `cong_nomination()`
- treaties with `cong_treaty()`
- hearings with `cong_hearing()`
## Authentication
To sign up for an API key, visit the [Congress.gov API](https://api.congress.gov/sign-up/) sign-up website.
Once you have your key, you can set it in your environment as `CONGRESS_KEY`.
You can:
1. Add this directly to your `.Renviron` file with a line like so
```r
CONGRESS_KEY='yourkey'
```
If doing this, I recommend using `usethis::edit_r_environ()` to ensure that you open the correct .Renviron file.
2. Set this in you current R session with `Sys.setenv(CONGRESS_KEY='yourkey')`.
3. Set this using the `congress::set_congress_key()` function. To save this for future sessions, run with `install = TRUE`.