Intro | Search taxa | Taxon tree | Sources | Webservice | Statistics | Editors | Log in

Calling the RAS webservice from R

This example script was written in R version 3.4.4, for newer/older versions just try and see if it works (See
Available for MacOS X, Linux & Windows.

Paste the following code in the R Console (this is just an example)

See all available functions at Just click on the function you want to explore and "try it out"!

#install the required packages (comment if needed)
install.packages("jsonlite", repos="")

#Use the libraries
library(jsonlite) #

#Fill in the AphiaID you need
AphiaID <- 127160

#Build the URL to get the data from
url <- sprintf("", AphiaID);

#Get the actual data from the URL
classificationTree <- fromJSON(url)

#Walk the classification tree
currentTreeItem = classificationTree
while (!is.null(currentTreeItem )) {
	print(sprintf("ID: %d, RANK: %s, ScientificName: %s",
	#You can access the variables individually
	#Get next item in the tree
	currentTreeItem <- currentTreeItem$child;
Download this example.
Download elaborate example (match names).

Note there is a complete R package available that you can use. See the rOpenSci library 'worrms', available here:

This service is powered by LifeWatch Belgium
Learn more»
Website and databases developed and hosted by VLIZ · Page generated 2024-04-14 · contact: Anton Van de Putte