R-universe provides several APIs for programmatic access, requiring no authentication. Thanks to the APIs you can list universes, packages in an universe, get information on packages, perform searches.
You can interact with the API in two ways:
- Create API calls “manually” in the command-line or R.
- Use the universe R package available from rOpenSci’s R-universe.
This page demonstrates usage with {httr2} or {universe} directly.
6.1 Universe-specific APIs
API endpoints start with the universe URL.
This documentation uses https://jeroen.r-universe.dev as an example, but you can replace it with any universe URL.
limit: Maximum number of results (default: 100). Use the ls endpoint to determine the total number of packages and adjust the limit accordingly.
Example using {httr2}:
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 "6746caa4626a0c487b74e50f"
$ 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 6
..$ name : chr "Rodrigo Pires"
..$ email : chr "[email protected]"
..$ login : chr "bozaah"
..$ twitter: chr "@ecophysplants"
..$ uuid : int 11730095
..$ orcid : chr "0000-0001-7384-6849"
$ updated : int 1732690924
$ 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.
6.4 Database dump (all universes)
URL: https://r-universe.dev/api/dbdump
This API endpoint is not supported by the universe package yet.