Information submitted through the support site is private but is not hosted within your secure CDD Vault. Please do not include sensitive intellectual property in your support requests.

R Scripting Language

 

If you require the use of the scripting language R for your API programming, you will require the following three packages:

  • jsonlite,
  • RCur
  • httr


A simple example of an API call with R would look like this:

install.packages("jsonlite")
install.packages("RCurl")
install.packages("httr")
library(RCurl)
library(jsonlite)
library(httr)
data<-getURI("https://app.collaborativedrug.com/api/v1/vaults", httpheader = paste("X-CDD-Token:", TOKEN), .mapUnicode=FALSE)
fromJSON(data) 

Including .mapUnicode=FALSE is essential if any new lines are returned by the API (ex. molfiles) or you will receive an error.

 

Another example using R, a POST request, can be written like this:

install.packages("httr")
library(httr)
response<-POST("http://localhost:3000/api/v1/vaults/489978881/molecules", body='{"name": "empty", "projects": [938429932]}', add_headers(.headers = c("X-CDD-Token"=TOKEN)))
stop_for_status(response)
content(response) 
Have more questions? Submit a request

0 Comments

Article is closed for comments.