construct_comment_url: Create a URL for the Comments Endpoint

View source: R/construct-comment-url.R

construct_comment_urlR Documentation

Create a URL for the Comments Endpoint

Description

Takes the parameters available for the comments endpoint of the regulations.gov API, as described here under the comments section under API calls, and constructs a URL that can be used to retrieve the data specified. To understand how these parameters relate to the data, it may help to go the the regulations.gov search function and go to a specific docket or document and look at the associated comments.

Usage

construct_comment_url(
  key = NULL,
  commentId = NULL,
  attachments = NULL,
  postedDate = NULL,
  agencyId = NULL,
  searchTerm = NULL,
  commentOnId = NULL,
  lastModifiedDate = NULL,
  sort = NULL,
  page_number = 1,
  page_size = 250
)

Arguments

key

the API key passed in the function call; this may be NULL if the user has chosen to set up the key as an environmental variable instead with the function set_datagov_key. You can use "DEMO_KEY" for a very limited number of calls if needed.

commentId

a comment ID that uniquely identifies the comment.

attachments

character string "true" if you want the download links included for a comment, otherwise leave as NULL. Note the API only provides functionality for obtaining download link if you provide a comment ID with the commentId argument. You can see this under the Comment ID Section at the page for any specific comment (see the example here).

postedDate

character vector of length 1, representing a single posted date, or a vector of length 2, representing a date range beginning with the first element and ending at the second. Each element must be in the format yyyy-MM-dd.

agencyId

character string representing a government agency, for example, "CMS" or "EPA" or a character vector of multiple agencies

searchTerm

character string representing a search term to filter the results for or a character vector with multiple search terms to filter for.

commentOnId

character vector containing the objectIds of the documents for which you want to obtain comments.

lastModifiedDate

a character vector of length 1, representing a single posted date to filter for, or a vector of length 2, representing a date range beginning with the first element and ending at the second. Each element must be in the format yyyy-MM-dd HH:mm:ss.

sort

character string representing which value you want to sort the results by, supported variables are postedDate, lastModifiedDate and documentId.

page_number

character string representing which page to retrieve the data; useful when output is on multiple pages. Valid values are between 1 and 20. Default value is 1.

page_size

character string representing how many elements should be on each page. Valid values are between 5 and 250. The default value is 250.

Examples

construct_comment_url(
  agencyId = c("CMS", "EPA"),
  postedDate = c("2020-02-02", "2020-10-02"),
  key = "DEMO_KEY"
)
construct_comment_url(
  searchTerm = "case numbers",
  postedDate = c("2021-01-02", "2021-01-15"),
  key = "DEMO_KEY"
)

q-w-a/regulationsgov documentation built on May 3, 2022, 8:23 p.m.