On this page we’ll show examples using {httr2} or {universe} directly.
6.1 Universe-specific APIs
The URL of these APIs start with the universe URL. Here we will often use https://jeroen.r-universe.dev as an example but you can replace it with any universe URL.
limit: the number of results to return, by default a maximum of 100. You can use the ls endpoint to determine the total number of packages in the universe and set that as a limit.
Example:
packages <- httr2::request("https://jeroen.r-universe.dev/api/packages") |> httr2::req_user_agent("R-universe docs") |> httr2::req_perform() |> httr2::resp_body_json()# The result is a list of packagesstr(packages[[1]], max.level =1)
List of 5
$ results:List of 70
$ query :List of 1
$ skip : int 0
$ limit : int 100
$ total : int 70
str(packages$results[[1]])
List of 15
$ _id : chr "6739ea805fa4b4323b4f3275"
$ Package : chr "weatherOz"
$ Title : chr "An API Client for Australian Weather and Climate Data Resources"
$ Description : chr "Provides automated downloading, parsing and formatting of\nweather data for Australia through API endpoints pro"| __truncated__
$ _user : chr "ropensci"
$ _usedby : int 0
$ _searchresults: int 39
$ _score : num 8.53
$ _uuid : int 1200269
$ maintainer :List of 5
..$ name : chr "Rodrigo Pires"
..$ email: chr "[email protected]"
..$ login: chr "bozaah"
..$ uuid : int 11730095
..$ orcid: chr "0000-0001-7384-6849"
$ updated : int 1731804436
$ stars : int 27
$ topics :List of 19
..$ : chr "dpird"
..$ : chr "bom"
..$ : chr "meteorological-data"
..$ : chr "weather-forecast"
..$ : chr "australia"
..$ : chr "weather"
..$ : chr "weather-data"
..$ : chr "meteorology"
..$ : chr "western-australia"
..$ : chr "australia-bureau-of-meteorology"
..$ : chr "western-australia-agriculture"
..$ : chr "australia-agriculture"
..$ : chr "australia-climate"
..$ : chr "australia-weather"
..$ : chr "api-client"
..$ : chr "climate"
..$ : chr "data"
..$ : chr "rainfall"
..$ : chr "weather-api"
$ match : num 170
$ rank : num 1453
Note that searching globally only returns “indexed” packages: if a package is included in several universes, it still shows up only once in search results because of our deduplication efforts.