For a source that ships a bulk flat file, CSV or TSV, rather than a
per-record JSON API. Same timeout, retry, caching, and header redaction as
get_json(); the body comes back verbatim as a string in data.
Usage
get_text(
base_url,
path = NULL,
query = list(),
source = "API",
timeout = 30,
max_tries = 3,
headers = NULL,
throttle = NULL,
secret_query = NULL
)Arguments
- base_url
The service's base URL.
- path
An optional path appended to
base_url.- query
A named list of query parameters. Blank values are dropped.
- source
A friendly label for the service.
- timeout
Seconds before the request is abandoned.
- max_tries
Total attempts, including the first.
- headers
A named list of headers, all marked sensitive.
- throttle
An optional throttle spec. See
req_defaults().- secret_query
A named list of query-string credentials, for a service that has no header form. Deliberately not part of the cache key, so it suits a credential that raises a rate limit and not one that changes the response. See
redact_secrets().
Details
The success-only cache means the file is fetched once per URL and every later lookup against it is served in process.
Examples
cache_reset()
breaker_reset()
httr2::with_mocked_responses(
list(httr2::response(
status_code = 200,
body = charToRaw("gene\tclassification\nBRCA1\tDefinitive\n")
)),
get_text(
"https://search.clinicalgenome.org",
path = "kb/gene-validity/download",
source = "ClinGen"
)$data
)
#> [1] "gene\tclassification\nBRCA1\tDefinitive\n"