Title: | Query the 'NHS TRUD API' |
---|---|
Description: | A convenient R interface to the 'National Health Service (NHS) Technology Reference Update Distribution (TRUD) API'. Retrieve available releases for items that you are subscribed to and download these with ease. For more information on the API, see <https://isd.digital.nhs.uk/trud/users/guest/filters/0/api>. |
Authors: | Alasdair Warwick [aut, cre, cph] , Robert Luben [aut] , Abraham Olvera-Barrios [aut] , Chuin Ying Ung [aut] |
Maintainer: | Alasdair Warwick <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0.9000 |
Built: | 2024-10-30 05:31:02 UTC |
Source: | https://github.com/rmgpanw/trud |
Downloads files for a specified NHS TRUD item (requires a subscription). By default this is the latest release.
download_item( item, directory = ".", download_file = "archive", TRUD_API_KEY = NULL, release = NULL )
download_item( item, directory = ".", download_file = "archive", TRUD_API_KEY = NULL, release = NULL )
item |
An integer, the item to be downloaded. |
directory |
Path to the directory to which this item will be downloaded to. This is set to the current working directory by default. |
download_file |
The item file to be downloaded. Valid values:
|
TRUD_API_KEY |
A string. The name of an environmental variable
containing your TRUD API key. If |
release |
The name of a specific release ID to be downloaded (this can
be ascertained using |
The file path to the downloaded file, returned invisibly.
## Not run: # Download Community Services Data Set pre-deadline extract XML Schema x <- download_item(394, directory = tempdir()) # List downloaded files unzip(x, list = TRUE) # Download a previous release release <- get_item_metadata(394)$releases[[2]]$id y <- download_item(394, directory = tempdir(), release = release) unzip(y, list = TRUE) ## End(Not run) # An informative error is raised if your API key is invalid or missing try(download_item(394, TRUD_API_KEY = "INVALID_API_KEY"))
## Not run: # Download Community Services Data Set pre-deadline extract XML Schema x <- download_item(394, directory = tempdir()) # List downloaded files unzip(x, list = TRUE) # Download a previous release release <- get_item_metadata(394)$releases[[2]]$id y <- download_item(394, directory = tempdir(), release = release) unzip(y, list = TRUE) ## End(Not run) # An informative error is raised if your API key is invalid or missing try(download_item(394, TRUD_API_KEY = "INVALID_API_KEY"))
Sends a request to the release list endpoint, returning a list of metadata pertaining to the specified NHS TRUD item.
get_item_metadata(item, TRUD_API_KEY = NULL, latest_only = FALSE)
get_item_metadata(item, TRUD_API_KEY = NULL, latest_only = FALSE)
item |
An integer, the item to be downloaded. |
TRUD_API_KEY |
A string. The name of an environmental variable
containing your TRUD API key. If |
latest_only |
If |
A list.
## Not run: # Get metadata for Community Services Data Set pre-deadline extract XML Schema get_item_metadata(394) |> purrr::map_at("releases", \(release) purrr::map(release, names)) # Include metadata for any previous releases using `latest_only = FALSE` get_item_metadata(394, latest_only = FALSE) |> purrr::map_at("releases", \(release) purrr::map(release, names)) ## End(Not run) # An informative error is raised if your API key is invalid or missing try(download_item(394, TRUD_API_KEY = "INVALID_API_KEY"))
## Not run: # Get metadata for Community Services Data Set pre-deadline extract XML Schema get_item_metadata(394) |> purrr::map_at("releases", \(release) purrr::map(release, names)) # Include metadata for any previous releases using `latest_only = FALSE` get_item_metadata(394, latest_only = FALSE) |> purrr::map_at("releases", \(release) purrr::map(release, names)) ## End(Not run) # An informative error is raised if your API key is invalid or missing try(download_item(394, TRUD_API_KEY = "INVALID_API_KEY"))
A convenience wrapper around trud_items()
and get_item_metadata()
,
retrieving metadata for only items that the user is subscribed to.
get_subscribed_metadata(TRUD_API_KEY = NULL, latest_only = FALSE)
get_subscribed_metadata(TRUD_API_KEY = NULL, latest_only = FALSE)
TRUD_API_KEY |
A string. The name of an environmental variable
containing your TRUD API key. If |
latest_only |
If |
A tibble, with item metadata stored in the list column metadata
.
trud_items()
, get_item_metadata()
## Not run: get_subscribed_metadata() ## End(Not run)
## Not run: get_subscribed_metadata() ## End(Not run)
Scrapes this page from the NHS TRUD website for all available items.
trud_items()
trud_items()
A tibble, with columns item_number
and item_name
.
## Not run: trud_items() ## End(Not run)
## Not run: trud_items() ## End(Not run)