| fetch_cms_data | R Documentation | 
This function retrieves data from the provided link and returns it as a tibble
with cleaned names. This function is intended to be used with the CMS data API
function get_cms_meta_data.
fetch_cms_data(.data_link)
.data_link | 
 A character string containing the URL to fetch data from.  | 
The function sends a request to the provided URL using httr2::request and
httr2::req_perform. If the response status is not 200, it stops with an
error message indicating the failure. The response body is parsed as JSON and
converted into a tibble using dplyr::as_tibble. The column names are cleaned
using janitor::clean_names, and any character columns are stripped of leading
and trailing whitespace using stringr::str_squish.
A tibble containing the fetched data with cleaned names. If an error
occurs, returns NULL.
get_cms_meta_data
library(dplyr)
# Example usage:
base_url <- "https://data.cms.gov/data-api/v1/dataset/"
data_identifier <- "9767cb68-8ea9-4f0b-8179-9431abc89f11"
data_url <- paste0(base_url, data_identifier, "/data")
df_tbl <- fetch_cms_data(data_url)
df_tbl |>
 head(1) |>
 glimpse()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.