NAV

Introduction

Welcome to the DrugBank API! You can use our API to access DrugBank API endpoints, which can get information on drugs, drug products, and drug interactions in our database.

The DrugBank API is organized around REST. Our API has predictable, resource-oriented URLs, and uses HTTP response codes to indicate API errors. We use built-in HTTP features, like HTTP authentication and HTTP verbs, which are understood by off-the-shelf HTTP clients. JSON is returned by all API responses, including errors, although our API libraries convert responses to appropriate language-specific objects.

We have language bindings in Shell, Ruby, and Javascript. You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.

Authentication

To authorize, use this code:

# With cURL, you can just pass the correct header with each request
curl -L 'https://api.drugbank.com/v1/endpoint' 
-H 'Authorization: myapikey'

Make sure to replace myapikey with your development or production API key.

DrugBank uses API keys to allow access to the API. To request an API key please contact us.

All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.

DrugBank expects for the API key to be included in all API requests to the server in a header that looks like the following:

Authorization: myapikey

Production Key

Your production key is the authentication token you receive upon sign up. This key does not have a limit in regards to the amount of calls you can make. Any API calls that exceed your quota (if applicable) will be permitted but counted as overage.

Development Key

A development key is a second API key which, unlike the production key, caps the number of allowed requests at 3000 requests/month.

The request limit is to meant to prevent runwaway programs from making calls that exceed your expected usage during the development process. The development key should be kept secret and only be shared with your developers in order to ensure that if a mistake happens during programming, it can be fixed without affecting the production key.

Token Authentication

To get a token that expires in 12 hours, use this code:

curl -L -X POST 'https://api.drugbank.com/v1/tokens' \ 
-H 'Content-Type: application/json' \ 
-H 'Authorization: myapikey' \ 
-H 'Cache-Control: no-cache' -d '{
  "ttl": 12
}'

Example command returns JSON structured like this (results may be abbreviated):

{
  "token": "eyJhbGciOiJIUzI1NiJ9.eyJrZXlfaWQiOjk5MiwiZXhwIjoxNjI0MzU2MDA0fQ.kznCei1SsMMlYBH9e6SGlP_sqYmx_5uXatyR8gZZr3M"
}

The following will request a token that expires in 15 minutes:

curl -L -X POST 'https://api.drugbank.com/v1/tokens' \ 
-H 'Content-Type: application/json' \ 
-H 'Authorization: myapikey' \ 
-H 'Cache-Control: no-cache' -d '{
  "ttl": "15m"
}'

Example command returns JSON structured like this (results may be abbreviated):

{
  "token": "eyJhbGciOiJIUzI1NiJ9.eyJrZXlfaWQiOjk5MiwiZXhwIjoxNjI0MzU2MDA0fQ.kznCei1SsMMlYBH9e6SGlP_sqYmx_5uXatyR8gZZr3M"
}

To authorize a request using an API token, use this code:

curl -L 'https://api.drugbank.com/v1/endpoint' 
-H 'Authorization: Bearer mytoken'

To authorize a browser-based request using an API token, use this code:

const xhr = new XMLHttpRequest();
const url = 'https://api-js.drugbank.com/v1/endpoint';

xhr.open('GET', url);
xhr.setRequestHeader('Authorization', 'Bearer mytoken');
xhr.send();

Alternatively you can use tokens to get access to the DrugBank APIs. Tokens allow short term access to DrugBank API without exposing your secret API key. They are guaranteed to expire within 24 hours. The use of token authentication is required for accessing DrugBank APIs from browser-based applications.

Token life time

The default expiry of a token is 24 hours after it was created. The lifetime of a token can be set with the ttl parameter on creation. When set, the ttl is the number of hours the token is valid for, with a maximum of 24 hours. If no unit is given, the ttl is assumed to be in hours. The value can also be sent as a string with a unit attached (“m” for minutes or “h” for hours). A ttl of “15m” will request a token that exires in 15 minutes.

Web browser-based application API authentication

Web browser-based applications are permitted to access the DrugBank APIs through:

https://api-js.drugbank.com

All API calls, as described in this documentation, are identical – with the exception of the web address and the authentication method. Token based authentication is required to access the web compatible API.

It is recommend that tokens for use in your web browser-based applications are generated from an internal service that you can authenticate your users against. This way your secret key is not exposed and you can control who has access to your DrugBank subscription.

Errors

The DrugBank API uses conventional HTTP response codes to indicate the success or failure of an API request. In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that failed given the information provided (e.g., a required parameter was omitted), and codes in the 5xx range indicate an error with DrugBank servers (these are rare).

The DrugBank API uses the following error codes:

Error Code Meaning
400 Bad Request – Your request is invalid
401 Unauthorized – Your API key is wrong
404 Not Found – The specified resource could not be found
405 Method Not Allowed – You tried to access a resource with an invalid method
406 Not Acceptable – You requested a format that isn’t json
410 Gone – The resource requested has been removed from our servers
429 Too Many Requests – You’re making too many requests! Slow down!
500 Internal Server Error – We had a problem with our server. Try again later.
503 Service Unavailable – We’re temporarially offline for maintanance. Please try again later.

Drug Names / Autocomplete

This endpoint returns a list of drugs/product information suitable for use with autocomplete forms, for quickly finding the right drugs/products.

curl -L 'https://api.drugbank.com/v0/drug_names.json?search=tylenol' 
-H 'Authorization: myapikey'

Example command returns JSON structured like this (results may be abbreviated):

{
  "products": [
    {
      "hits": [
        {
          "field": "name",
          "value": "<em>Tylenol</em> PM"
        },
        {
          "field": "prescribable_name",
          "value": "<em>Tylenol</em> PM 500 mg / 25 mg Oral Tablet"
        }
      ],
      "name": "Tylenol PM",
      "ndc_product_codes": [
        "73097-0013"
      ],
      "dosage_form": "Tablet, film coated",
      "strength_number": null,
      "strength_unit": null,
      "route": "Oral",
      "generic": false,
      "otc": true,
      "mixture": true,
      "ingredients": [
        {
          "drugbank_id": "DB00316",
          "name": "Acetaminophen",
          "cas": "103-90-2",
          "strength_number": "500",
          "strength_unit": "mg/1"
        },
        {
          "drugbank_id": "DB01075",
          "name": "Diphenhydramine",
          "cas": "58-73-1",
          "strength_number": "25",
          "strength_unit": "mg/1"
        }
      ],
      "images": []
    },
    {
      "hits": [
        {
          "field": "name",
          "value": "<em>Tylenol</em> PM"
        },
        {
          "field": "prescribable_name",
          "value": "<em>Tylenol</em> PM 500 mg / 25 mg Oral Tablet"
        }
      ],
      "name": "Tylenol PM",
      "ndc_product_codes": [
        "50269-0608"
      ],
      "dosage_form": "Tablet",
      "strength_number": null,
      "strength_unit": null,
      "route": "Oral",
      "generic": false,
      "otc": true,
      "mixture": true,
      "ingredients": [
        {
          "drugbank_id": "DB00316",
          "name": "Acetaminophen",
          "cas": "103-90-2",
          "strength_number": "500",
          "strength_unit": "mg/1"
        },
        {
          "drugbank_id": "DB01075",
          "name": "Diphenhydramine",
          "cas": "58-73-1",
          "strength_number": "25",
          "strength_unit": "mg/1"
        }
      ],
      "images": []
    },
    "..."
  ]
}

HTTP Request

GET https://api.drugbank.com/v0/drug_names.json

Query Parameters

Parameter Default Description
search null The string you want to search with.
fuzzy false If set to true, enable fuzzy search (see fuzzy searching below)

Notice the hits array returned in the results. The hits contain highlighted snippets from the match. You can use these highlights in autocomplete applications. The matching part of the text is wrapped in an <em> tag, which you can style as you wish in your application.

curl -L 'https://api.drugbank.com/v0/drug_names/simple.json?search=tylenol' 
-H 'Authorization: myapikey'

Example command returns JSON structured like this (results may be abbreviated):

{
  "products": [
    {
      "hits": [
        {
          "field": "name",
          "value": "<em>Tylenol</em> 52.63% Oral Powder"
        }
      ],
      "name": "Tylenol 52.63% Oral Powder",
      "brands": [
        "TYLENOL Extra Strength"
      ],
      "ndc_product_codes": [
        "50580-0209"
      ],
      "dosage_forms": "Powder",
      "strength_number": "500",
      "strength_unit": "mg/0.95g",
      "route": "Oral",
      "ingredients": [
        {
          "drugbank_id": "DB00316",
          "name": "Acetaminophen",
          "cas": "103-90-2",
          "strength_number": "500",
          "strength_unit": "mg/0.95g"
        }
      ]
    },
    {
      "hits": [
        {
          "field": "name",
          "value": "<em>Tylenol</em> 500 mg Oral Tablet"
        }
      ],
      "name": "Tylenol 500 mg Oral Tablet",
      "brands": [
        "TYLENOL Acetaminophen Extra Strength",
        "Tylenol Extra Strength"
      ],
      "ndc_product_codes": [
        "29485-1887",
        "50580-0451",
        "..."
      ],
      "dosage_forms": "Tablet, coated",
      "strength_number": "500",
      "strength_unit": "mg/1",
      "route": "Oral",
      "ingredients": [
        {
          "drugbank_id": "DB00316",
          "name": "Acetaminophen",
          "cas": "103-90-2",
          "strength_number": "500",
          "strength_unit": "mg/1"
        }
      ]
    },
    "..."
  ]
}

Prescribable name (simple) search uses the concept of a prescribable name, the normalized, most common name used to describe a medication. The results of this search will not contain multiple brand names for a given drug. Instead the prescribable name will be unique for a dosage strength/form and a name.

This type of search is useful when logging medications a customer/patient may be taking. You can combine a name and a dosage strength to quickly filter your search. For example searching for viagra 25 mg will quickly return the most likely drug that the individual is taking.

HTTP Request

GET https://api.drugbank.com/v0/drug_names/simple.json

Query Parameters

Parameter Default Description
search null The string you want to search with.
fuzzy false If set to true, enable fuzzy search (see fuzzy searching below)

Notice the hits array returned in the results. The hits contain highlighted snippets from the match. You can use these highlights in autocomplete applications. The matching part of the text is wrapped in an <em> tag, which you can style as you wish in your application.

Fuzzy Searching

This example demonstrates a misspelling of “Advil”, with fuzzy search enabled you will still get a result (try it yourself!).

curl -L 'https://api.drugbank.com/v0/drug_names.json?search=addvil&fuzzy=true' 
-H 'Authorization: myapikey'

Fuzzy searching allows for misspellings, but is not enabled by default, you must set fuzzy=true. By setting fuzzy=true you are telling the API to allow a certain number of misspellings to still count as a match (defaults to 2). You can also pass a number of misspellings in to increase the likelyhood of a match (for example, fuzzy=4 will allow 4 misspelled letters).

Products

Get a specific U.S. product

curl -L 'https://api.drugbank.com/v0/products/55154-2727' 
-H 'Authorization: myapikey'

Example command returns JSON structured like this (results may be abbreviated):

{
  "ndc_product_code": "55154-2727",
  "dpd_id": null,
  "name": "Viagra",
  "started_marketing_on": "1998-03-27",
  "approved_on": null,
  "schedule": null,
  "dosage_form": "Tablet, film coated",
  "route": "Oral",
  "application_number": "NDA020895",
  "generic": false,
  "otc": false,
  "approved": true,
  "mixture": false,
  "country": "US",
  "ingredients": [
    {
      "name": "Sildenafil",
      "drugbank_id": "DB00203",
      "strength": {
        "number": "25",
        "unit": "mg/1"
      }
    }
  ]
}

This endpoint retrieves a specific drug product based on NDC ID.

HTTP Request

GET https://api.drugbank.com/v0/products/<NDC_ID>

URL Parameters

Parameter Description
ID The NDC ID of the product to retrieve

Drugs

Get a specific drug

curl -L 'https://api.drugbank.com/v0/drugs/DB00316' 
-H 'Authorization: myapikey'

Example command returns JSON structured like this (results may be abbreviated):

{
  "drugbank_id": "DB00316",
  "name": "Acetaminophen",
  "description": "Acetaminophen (paracetamol), also commonly known as _Tylenol_, is the most commonly taken analgesic worldwide and is recommended as first-line therapy ...",
  "synonyms": [
    "4'-hydroxyacetanilide",
    "4-(Acetylamino)phenol",
    "..."
  ],
  "pharmacology": {
    "indication_description": "In general, acetaminophen is used for the treatment of mild to moderate pain and reduction of fever...",
    "pharmacodynamic_description": "Animal and clinical studies have determined that acetaminophen has both antipyretic and analgesic effects...",
    "mechanism_of_action_description": "According to its FDA labeling, acetaminophen's exact mechanism of action has not been fully established[Label] - despite this, it is often categorized ...",
    "absorption": "Acetaminophen has 88% oral bioavailability and reaches its highest plasma concentration 90 minutes after ingestion...",
    "protein_binding": "The binding of acetaminophen to plasma proteins is low (ranging from 10% to 25%), when given at therapeutic doses.[Label]",
    "volume_of_distribution": [
      "Volume of distribution is about 0..."
    ],
    "clearance": [
      "Adults: 0.27 L/h/kg following a 15 mg/kg intravenous (IV) dose.[Label]",
      "Children: 0.34 L/h/kg following a 15 mg/kg intravenous (IV dose).[Label]"
    ],
    "half_life": "The half-life for adults is 2...",
    "route_of_elimination": "Acetaminophen metabolites are mainly excreted in the urine...",
    "toxicity_description": "LD50 = 338 mg/kg (oral, mouse); LD50 = 1944 mg/kg (oral, rat)[F4133]\r\n\r\n**Overdose and liver toxicity** \r\n\r\nAcetaminophen overdose may be manifested by..."
  },
  "identifiers": {
    "drugbank_id": "DB00316",
    "inchi": "InChI=1S/C8H9NO2/c1-6(10)9-7-2-4-8(11)5-3-7/h2-5,11H,1H3,(H,9,10)",
    "inchikey": "RZVAJINKPMORJF-UHFFFAOYSA-N"
  }
}

This endpoint retrieves a specific drug based on DrugBank ID.

HTTP Request

GET https://api.drugbank.com/v0/drugs/<ID>

URL Parameters

Parameter Description
ID The DrugBank ID of the drug to retrieve

Get products linked with a drug

curl -L 'https://api.drugbank.com/v0/drugs/DB00316/products' 
-H 'Authorization: myapikey'

Example command returns JSON structured like this (results may be abbreviated):

[
  {
    "ndc_product_code": null,
    "dpd_id": "02236871",
    "name": "(extra Strength) Acetaminophen, Caffeine & 8mg Codeine Phosphate Caplets",
    "started_marketing_on": "1998-07-22",
    "approved_on": null,
    "schedule": "Narcotic (CDSA I)",
    "dosage_form": "Tablet",
    "route": "Oral",
    "application_number": null,
    "generic": false,
    "otc": false,
    "approved": true,
    "mixture": true,
    "country": "Canada",
    "ingredients": [
      {
        "name": "Codeine",
        "drugbank_id": "DB00318",
        "strength": {
          "number": "8",
          "unit": "mg"
        }
      },
      {
        "name": "Acetaminophen",
        "drugbank_id": "DB00316",
        "strength": {
          "number": "500",
          "unit": "mg"
        }
      },
      "..."
    ]
  }
]

This endpoint retrieves a list of products linked to a drug, based on DrugBank ID.

HTTP Request

GET https://api.drugbank.com/v0/drugs/<ID>/products

URL Parameters

Parameter Description
ID The DrugBank ID of the drug to retrieve the linked products

Drug-Drug Interactions

Provide a list of products to get a list of interactions between the ingredients in specified products. The products can be specified by name or by product code.

Find DDI With Product Codes

Return a list of drug interactions involving the products with the NDC codes 66715-9833 and 0002-7140:

curl -L 'https://api.drugbank.com/v0/ddi?ndc=66715-9833,0002-7140' 
-H 'Authorization: myapikey'

Example command returns JSON structured like this (results may be abbreviated):

{
  "total_results": 1,
  "interactions": [
    {
      "product": "66715-9833",
      "product_name": "7-Select Advil PM",
      "product_ingredient": {
        "drugbank_id": "DB01050",
        "name": "Ibuprofen"
      },
      "affected_product": "00002-7140",
      "affected_product_name": "Reopro",
      "affected_product_ingredient": {
        "drugbank_id": "DB00054",
        "name": "Abciximab"
      },
      "action": "increase_specific_adverse_effects",
      "description": "The risk or severity of bleeding can be increased when Ibuprofen is combined with Abciximab.",
      "severity": "moderate"
    }
  ]
}

HTTP Request

GET https://api.drugbank.com/v0/ddi

Query Parameters

Parameter Description
names A comma delimited list of NDC codes

To search by the NDC product code the ndc codes should be joined with a comma, and not include any quotations. Only the 2 segment NDC code is accepted at this time.

Find DDI With Name

Return a list of drug interactions involving the products with the products named: advil, Reopro, Eliquis and 7-select Advil PM.

curl -L -X POST 'https://api.drugbank.com/v0/ddi' \ 
-H 'Content-Type: application/json' \ 
-H 'Authorization: myapikey' \ 
-H 'Cache-Control: no-cache' -d '{
  "names": [
    "advil",
    "Reopro",
    "Eliquis",
    "7-select Advil PM"
  ]
}'

Example command returns JSON structured like this (results may be abbreviated):

{
  "total_results": 6,
  "interactions": [
    {
      "product_name": "7-Select Advil PM",
      "product_ingredient": {
        "drugbank_id": "DB01050",
        "name": "Ibuprofen"
      },
      "affected_product_name": "Reopro",
      "affected_product_ingredient": {
        "drugbank_id": "DB00054",
        "name": "Abciximab"
      },
      "action": "increase_specific_adverse_effects",
      "description": "The risk or severity of bleeding can be increased when Ibuprofen is combined with Abciximab.",
      "severity": "moderate"
    },
    {
      "product_name": "Advil",
      "product_ingredient": {
        "drugbank_id": "DB01050",
        "name": "Ibuprofen"
      },
      "affected_product_name": "Reopro",
      "affected_product_ingredient": {
        "drugbank_id": "DB00054",
        "name": "Abciximab"
      },
      "action": "increase_specific_adverse_effects",
      "description": "The risk or severity of bleeding can be increased when Ibuprofen is combined with Abciximab.",
      "severity": "moderate"
    },
    "..."
  ]
}

HTTP Request

POST https://api.drugbank.com/v0/ddi

Request Body

To search for drug-drug interactions by drug product name JSON specifying the request should be included in the body of the request. The format of the request should follow the structure of the following example:

{"names": ["advil","Reopro","Eliquis","7-select Advil PM"]}

The API finds the product with the closest match to the input name, and returns any interactions between ingredients for all the products in the product list.

API Versions

Accessing API versions

All previous versions of our API documentation are available:

Version Link Released
v0 https://docs.drugbank.com/v0 July, 2016
v1 https://docs.drugbank.com/v1 September, 2016 (Current)

You can access the latest version of the API docs using the base docs url:

https://docs.drugbank.com

This will redirect you to the newest version of the API.