New cran.dev shortlinks to package information and documentation

[This article was first published on rOpenSci - open tools for open science, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Introducing cran.dev shortlinks!

On r-universe you can find package repositories from many different organizations and maintainers. But sometimes you just want to lookup a particular CRAN package, without knowing the developer. The new cran.dev shortlink service lets you navigate or link directly to the r-universe homepage and docs of any established CRAN package.

The root domain https://cran.dev/{package} redirects to the primary homepage for a package:

The subdomain https://docs.cran.dev/{package} redirects to package manual page:

Finally the subdomain https://api.cran.dev/{package} does not redirect, but returns a JSON blob with links to the package versions and resources. For example:

This shows the package page and maintainer for the gert package, and information on both the current CRAN release and development versions. Right now it returns:

{
 "package": "gert",
 "maintainer": "Jeroen Ooms <[email protected]>",
 "home": "https://ropensci.r-universe.dev/gert",
 "release": {
 "version": "1.9.2",
 "date": "2023-06-30T08:43:26.000Z",
 "source": "https://github.com/cran/gert",
 "repository": "https://cloud.r-project.org",
 "docs": "https://cran.r-universe.dev/gert/doc/manual.html",
 "api": "https://cran.r-universe.dev/api/packages/gert"
 },
 "devel": {
 "version": "1.9000",
 "date": "2023-07-20T11:08:09.000Z",
 "source": "https://github.com/r-lib/gert",
 "repository": "https://ropensci.r-universe.dev",
 "docs": "https://ropensci.r-universe.dev/gert/doc/manual.html",
 "api": "https://ropensci.r-universe.dev/api/packages/gert"
 }
}

We can see the release and devel version of this package, with links to the respective sources, cranlike repository, manual, and package metadata.

From the above it can be seen that the gert r-universe page is https://ropensci.r-universe.dev/gert and the r-universe "repository" from where to install the devel version of gert:

# install 'devel' gert
install.packages("gert", repos = "https://ropensci.r-universe.dev")

The "api" field shows the JSON url with all the information and metadata about this package:

# Everything there is to know about devel gert
gert <- jsonlite::fromJSON('https://ropensci.r-universe.dev/api/packages/gert')

Note that not all packages have a devel version available. CRAN packages that are not found GitHub or GitLab or r-forge only have a release version, for example: https://api.cran.dev/MASS

To leave a comment for the author, please follow the link and comment on their blog: rOpenSci - open tools for open science.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)