Package 'govinfoR'

Title: A 'GovInfo' API Wrapper
Description: Access data provided by the United States Government Publishing Office (GPO) 'GovInfo' API (<https://github.com/usgpo/api>).
Authors: William Blackerby [aut, cre, cph]
Maintainer: William Blackerby <[email protected]>
License: MIT + file LICENSE
Version: 0.0.3.9000
Built: 2025-03-20 02:59:41 UTC
Source: https://github.com/blackerby/govinfor

Help Index


Retrieve GPO collections data

Description

The following params correspond to those listed in the GovInfo API documentation], but the offset param is not supported. GovInfo documentation indicates that it was to be deprecated in December, 2022, and though it is still available through the API, the offsetMark parameter is supported instead. Parameter descriptions are adapted from GovInfo API documentation.

Usage

gpo_collections(
  collection = NULL,
  start_date = NULL,
  end_date = NULL,
  page_size = 10,
  doc_class = NULL,
  congress = NULL,
  bill_version = NULL,
  court_code = NULL,
  court_type = NULL,
  state = NULL,
  topic = NULL,
  is_glp = NULL,
  nature_suit_code = NULL,
  nature_suit = NULL,
  offset_mark = "*"
)

Arguments

collection

The collectionCode that you want to retrieve (e.g. BILLS, CREC, FR, PLAW, USCOURTS)

start_date

ISO8601 date and time formatted string (yyyy-MM-dd'T'HH:mm:ss'Z') Example: 2018-01-28T20:18:10Z

end_date

ISO8601 date and time formatted string (yyyy-MM-dd'T'HH:mm:ss'Z') Example: 2018-01-28T20:18:10Z

page_size

The number of records to return for a given request.

doc_class

Filter by collection-specific categories, which vary among collections.

congress

Filter by Congress, e.g., 116, 117

bill_version

Specific to the BILLS collection. Filter by bill text version code.

court_code

USCOURTScollection specific.

court_type

USCOURTS collection specific.

state

Collection specific.

topic

Collection specific.

is_glp

Collection specific.

nature_suit_code

Collection specific.

nature_suit

Collection specific.

offset_mark

Indicates starting record for a given request.

Details

Calling gpo_collections() without specifying a collection returns metadata about all collections.

Value

A tibble

Examples

gpo_collections(collection = "BILLS", start_date = "2024-02-17T00:00:00Z")
gpo_collections()

Given a GPO package id, get a list of granules associated with that package.

Description

The offset param provide by the API is not supported. GovInfo documentation indicates that it was to be deprecated in December, 2022, and though it is still available through the API, the offsetMark parameter is supported instead. Parameter descriptions are adapted from GovInfo API documentation.

Usage

gpo_package_granules(
  package_id,
  page_size = 20,
  offset_mark = "*",
  md5 = NULL,
  granule_class = NULL
)

Arguments

package_id

String. The Package Id. Ex: CREC-2018-01-04

page_size

Integer. The number of records to retrieve per request. Defaults to 20.

offset_mark

Indicates starting record for a given request.

md5

String. md5 hash value of the html content file - can be used to identify changes in individual granules for the HOB and CRI collections.

granule_class

String. Filter the results by overarching collection-specific categories. Varies by collection.

Value

A tibble

Examples

gpo_package_granules("CREC-2018-01-04")

Given a package id and a granule id, return a metadata summary for the granule.

Description

Given a package id and a granule id, return a metadata summary for the granule.

Usage

gpo_package_granules_summary(package_id, granule_id)

Arguments

package_id

String. The Package Id. Ex: CREC-2018-01-04

granule_id

String. The granule ID, e.g. CREC-2018-01-04-pt1-PgD7-2

Value

A single row tibble

Examples

gpo_package_granules_summary("CREC-2018-01-04", "CREC-2018-01-04-pt1-PgD7-2")

Given a GPO package id, return summary metadata for that package.

Description

Given a GPO package id, return summary metadata for that package.

Usage

gpo_package_summary(package_id)

Arguments

package_id

String. The Package Id. Ex: CREC-2018-01-04

Value

A single row tibble.

Examples

gpo_package_summary("CREC-2018-01-04")

Retrieve documents based on official publication date.

Description

The following params correspond to those listed in the GovInfo API documentation, but the offset param is not supported. GovInfo documentation indicates that it was to be deprecated in December, 2022, and though it is still available through the API, the offsetMark parameter is supported instead. Parameter descriptions are adapted from GovInfo API documentation.

Usage

gpo_published(
  start_date,
  end_date = NULL,
  page_size = 10,
  collection,
  congress = NULL,
  doc_class = NULL,
  bill_version = NULL,
  modified_since = NULL,
  court_code = NULL,
  court_type = NULL,
  state = NULL,
  topic = NULL,
  nature_suit_code = NULL,
  nature_suit = NULL,
  offset_mark = "*",
  is_glp = NULL
)

Arguments

start_date

ISO8601 date and time formatted string (yyyy-MM-dd'T'HH:mm:ss'Z') Example: 2018-01-28T20:18:10Z

end_date

ISO8601 date and time formatted string (yyyy-MM-dd'T'HH:mm:ss'Z') Example: 2018-01-28T20:18:10Z

page_size

The number of records to return for a given request.

collection

Filter by GPO collection.

congress

Filter by Congress, e.g., 116, 117

doc_class

Filter by collection-specific categories, which vary among collections.

bill_version

Specific to the BILLS collection. Filter by bill text version code.

modified_since

Request only packages modified since a given date/time. ISO8601 date and time formatted string (yyyy-MM-dd'T'HH:mm:ss'Z') Example: 2018-01-28T20:18:10Z

court_code

USCOURTScollection specific.

court_type

USCOURTS collection specific.

state

Collection specific.

topic

Collection specific.

nature_suit_code

Collection specific.

nature_suit

Collection specific.

offset_mark

Indicates starting record for a given request.

is_glp

Collection specific.

Value

A tibble

Examples

gpo_published(
  start_date = "2024-01-01",
  end_date = "2024-01-03",
  collection = c("BILLS")
)

Check or Get GovInfo API Key

Description

Adapted, with gratitude, from Christopher Kenny's congress package

Usage

has_govinfo_key()

get_govinfo_key()

Value

logical if has, key if get

Examples

has_govinfo_key()

next_req

Description

A callback for use with httr2::req_perform_iterative

Usage

next_req(resp, req)

Arguments

resp

Callback response.

req

Callback response.


Adds api.data.gov key to .Renviron

Description

Adds api.data.gov key to .Renviron

Usage

set_govinfo_key(key, overwrite = FALSE, install = FALSE)

Arguments

key

Character. API key to add.

overwrite

Defaults to FALSE. Boolean. Should existing GOVINFO_KEY in .Renviron be overwritten?

install

Defaults to FALSE. Boolean. Should key be added to '~/.Renviron' file?

Value

key, invisibly

Examples

## Not run: 
  set_govinfo_key("DEMO_KEY")

## End(Not run)

today

Description

A helper for specifying time stamps to the GovInfo API

Usage

today()

Value

String. Represents the earliest possible UTC time for today's date.

Examples

today()

tomorrow

Description

A helper for specifying time stamps to the GovInfo API

Usage

tomorrow()

Value

String. Represents the earliest possible UTC time for tomorrow's date.

Examples

tomorrow()

yesterday

Description

A helper for specifying time stamps to the GovInfo API

Usage

yesterday()

Value

String. Represents the earliest possible UTC time for the previous day.

Examples

yesterday()