Using VIPERdb web services

This is a guide to use the Viperdb Data Engine (VDE) in order to create custom tools using the data and functions of VIPERdb. All the services available at VIPERdb are published under the “web API”, (http://viperdb.scripps.edu/Web_Apis.php), found under the utilities tab. Inside the tool the user can access the name of the page and the parameters that each service can use. Here we show a couple of examples of how to implement the webservices using R and Python, these examples can be extended to any programing language that support web services and json format. The services are composed by a base a URL http://viperdb.scripps.edu/services/ and a service page name (family_index.php). Example:

http://viperdb.scripps.edu/services/family_index.php?serviceName=family_members&family=Bromoviridae

The above service retrieves all the members for a particular family (e.g., Bromoviridae) and the name of the family is specified by the family parameter.

Implementation of the webservice using Python

#libraries for the webservices
import requests
import json
r=requests.get("http://viperdb.scripps.edu/services/family_index.php?serviceName=family_members&family=Bromoviridae")
# Convert it to a Python dictionary
data = json.loads(r.text)
#print the data
for d in data:
  print(d)

Implementation of the webservice using R

#libraries for the webservices
library(jsonlite)
library("ape")
# Convert it to a data frame
jsonFile <- as.data.frame(fromJSON("http://viperdb.scripps.edu/services/family_index.php?serviceName=family_members&family=Bromoviridae"))
# print the data
show(jsonFile)