The following requirements are necessary if you want to use the scripting language Python for your API programming:
Python V2.7.x (or V3.x)
library: "requests" - see this page for details and installation
A simple example of looking at a particular molecule (using GET) would look like this:
import requests
base_url = "https://app.collaborativedrug.com/api/v1/vaults/<vault_id>/"
headers = {'X-CDD-token':'<YOUR TOKEN HERE>'}
url = base_url + "molecules/<molecule_id>"
response = requests.request("GET", url, headers=headers)
#to view the status, use:
print(response)
#to view the detailed JSON return content:
print(response.json())
Another example using POST to create a new compound, respectively a new batch of an existing molecule:
import requests
headers = {'X-CDD-token':<YOUR TOKEN HERE>"}
base_url = "https://app.collaborativedrug.com/api/v1/vaults/<vault_id>/"
url = base_url + "batches"
data = {
"molecule": {"smiles": "CCCCCO"},
"projects": ["YourProject"],
"batch_fields": {
"Date": "2018-04-15",
"Vendor":"SomeVendor" }
}
response = requests.post(url, headers=headers, json=data)
#to view the status, use:
print(response)
#to view the detailed JSON return content:
print(response.json())
In this case, the POST would compare to an existing structure with the given smiles string.