Get Drug Categories
Overview
This API endpoint retrieves the categories for a specific drug from a database. It provides detailed information about the drug's categories, including their names, IDs, and descriptions.
Endpoint
GET https://www.britelink.io/api/v1/drugs/{drugId}/categories
URL Parameters
drugId
(required): The unique identifier for the drug for which categories are being requested.
Request
To retrieve categories for a specific drug, make a GET request to the endpoint with the drug's ID. The drug ID is typically obtained from a previous API call or from the application's interface.
Example request:
curl -L 'http://britelink.io/api/v1/drugs/{drugId}/categories' \
-H 'Authorization: Bearer YOUR_API_KEY'
Replace {drugId}
with the actual BriteLink ID of the drug.
Javascript Example
const apiKey = process.env.BRITE_API_KEY;
// Function to fetch categories for a specific drug
const fetchData = async (drugId) => {
try {
const url = `http://britelink.io/api/v1/drugs/${drugId}/categories`; // Construct the URL with the drug ID
const response = await axios.get(url, {
headers: { Authorization: `Bearer ${apiKey}` },
params,
});
console.log(response.data);
} catch (error) {
console.error("Error fetching data:", error);
}
};
// In this example:
// - fetchData takes a drugId parameter.
// - The URL is dynamically constructed using the drugId.
// - When you want to fetch categories for a drug, you pass the drug ID to fetchData.
// Example usage
const exampleDrugId = "clrw9ar1w0000jq081pukhhhu"; // Replace with actual drug ID
fetchData(exampleDrugId); // Fetch categories for the specified drug ID
// To fetch more data for the same drug, you can call fetchData() again.
Response
The response is a JSON array containing objects with detailed information about each category related to the drug. Each object in the array includes the following fields:
id
: A unique identifier for the category.name
: The name of the category.meshId
: The Medical Subject Headings (MeSH) ID associated with the category.meshTreeNumbers
: The MeSH tree numbers for the category.atcCode
: The Anatomical Therapeutic Chemical (ATC) code associated with the category.atcLevel
: The ATC code level.categorizationKind
: The kind of categorization (e.g., 'therapeutic').synonyms
: Array of synonyms related to the category.description
: A brief description of the category.
Example response:
{
"levelOfAvailability": "C",
"drugPriority": "V",
"categories": {
"id": "clqjkjarq000149khcr13qjke",
"name": "Antibiotics",
"meshId": "MESH54321",
"meshTreeNumbers": "J01CR",
"atcCode": "J01CR02",
"atcLevel": 5,
"categorizationKind": "Medical",
"synonyms": "Anti-Infective Agents",
"description": "Medications for bacterial infections"
},
"therapeuticCategories": [
{
"id": "clrwap5bk0001l408iuo4ml9y",
"briteLinkId": "BR015",
"name": "Cephalosporin Antibiotics",
"meshId": " D002446",
"meshTreeNumbers": "D02.065.589.099",
"atcCode": "J01DD04",
"synonyms": "Rocephin",
"description": "Ceftriaxone is a third-generation cephalosporin antibiotic used to treat a wide range of bacterial infections. It works by inhibiting bacterial cell wall synthesis."
}
]
}
Error Handling
The API returns the following HTTP status codes in case of errors:
400 Bad Request
: The request is invalid or missing required parameters.404 Not Found
: No drug found with the provided ID.500 Internal Server Error
: An error occurred on the server while processing the request.
Pagination and Filtering
This endpoint in V1 does not support
Security
Requests to this endpoint must include an authorization header with a valid API key.