
Fetch a dataset from any URL, with automatic format detection
Source:R/data_access.R
morie_fetch.RdA universal data-access entry point. Given a URL, MORIE detects the
format from the HTTP Content-Type header (falling back to the
URL extension), downloads the resource, and parses it into an R
object. The behaviour is automatic by default but every step is
controllable: pass an explicit format, extra query
params, a zip_member to extract, or reader arguments
via ....
Usage
morie_fetch(
url,
format = c("auto", "csv", "tsv", "json", "xml", "html", "xlsx", "zip", "arcgis"),
params = NULL,
zip_member = "",
simplify = TRUE,
...
)Arguments
- url
The resource URL.
- format
One of
"auto"(default),"csv","tsv","json","xml","html","xlsx","zip","arcgis".- params
Optional named list appended to
urlas a URL-encoded query string.- zip_member
For
zipdownloads, the archive member to extract (matched by basename, then by substring).- simplify
For
json/xml/html, whether to simplify into a data.frame where possible (defaultTRUE).- ...
Passed to the underlying reader (e.g.
read.csvarguments, ormorie_fetch_arcgisarguments).
Details
Supported formats: csv, tsv, json, xml,
html, xlsx, zip (extract one member), and
arcgis (delegates to morie_fetch_arcgis).
Examples
# \donttest{
# Chicago open-data portal (Socrata), endpoints verified 2026-07.
df <- try(morie_fetch(
"https://data.cityofchicago.org/resource/ijzp-q8t2.csv",
format = "csv", params = list(`$limit` = 5)
))
js <- try(morie_fetch(
"https://data.cityofchicago.org/resource/ijzp-q8t2.json",
format = "json", params = list(`$limit` = 5)
))
# }