getJson: Get JSON from an API

View source: R/getJson.R

getJsonR Documentation

Get JSON from an API

Description

Get JSON from an API

Usage

getJson(url)

Arguments

url

character(1). Uniform Resource Locator (URL).

Details

Requires httr2 package to be installed.

Value

list.

Note

Updated 2023-09-14.

Examples

## Access the UCSC Genome Browser API.
url <- pasteUrl(
    "api.genome.ucsc.edu",
    "list",
    "ucscGenomes",
    protocol = "https"
)
if (goalie::isAnExistingUrl(url)) {
    json <- getJson(url)
    print(names(json))
}

## Access Ensembl genome assembly metadata.
## The Ensembl REST API server is prone to connection issues, so keeping
## disabled here in the working example.
## > url <- pasteUrl(
## >     "rest.ensembl.org",
## >     "info",
## >     "assembly",
## >     paste0(
## >         "Homo sapiens",
## >         "?", "content-type=application/json"
## >     ),
## >     protocol = "https"
## > )
## > if (goalie::isAnExistingUrl(url)) {
## >     json <- getJson(url)
## >     print(names(json))
## > }

steinbaugh/brio documentation built on Feb. 1, 2024, 6:42 p.m.