If this project helped, consider supporting it:
Install from CRAN:
install.packages("uscongress")
Install from the rOpenGov universe:
# Enable repository from ropengov
options(repos = c(
ropengov = 'https://ropengov.r-universe.dev',
CRAN = 'https://cloud.r-project.org'))
# Download and install uscongress
install.packages("uscongress")
get_congressional_records()Retrieve and process Congressional Record speeches from the U.S. Government Publishing Office API. Congressional Records are stored as raw text files; this code extracts and organizes the information into a structured format.
The result is a tibble where each row represents a single speech and includes the following fields:
This function queries the Congressional Record collection for a given congressional session and date range. It retrieves speeches from the House and Senate, processes associated metadata, and returns the results in a structured tibble. It supports optional limits on the number of speeches collected.
By default, if no date_from or date_to are specified, the function automatically sets the date range based on the congressional session provided.
The function fetches full speech content by retrieving and parsing associated granules from the GovInfo API.
get_congressional_records(API_KEY,
max_results = NULL,
date_from = NULL,
date_to = NULL,
congress_session = 117)
| Argument | Type | Description |
|---|---|---|
API_KEY |
String | Your GovInfo API key. Required to authenticate API requests. |
max_results |
Integer | Optional. Maximum number of speeches to retrieve. If NULL, retrieves all available speeches in the session and date range. |
date_from |
String | Optional. Start date ("YYYY-MM-DD") for filtering speeches. If NULL, determined automatically by congress_session. |
date_to |
String | Optional. End date ("YYYY-MM-DD") for filtering speeches. If NULL, determined automatically by congress_session. |
congress_session |
Integer | Congressional session number (e.g., 117 for 2021–2023). Defaults to 117. |
date_from and date_to are omitted, the function uses preset start and end dates for sessions from the 104th (1995–1997) through the 118th (2023–2025) Congress.nextOffsetMark system.https://api.govinfo.gov
CREC (Congressional Record)speeches <- get_congressional_records(
API_KEY = "your_api_key_here",
max_results = 50,
congress_session = 117
)
# View the first few speeches
head(speeches)