Authentication for the BriteLink Drug Information API
Overview
To access the Drug Information API authentication is required. We use API keys for a secure and straightforward authorization process.
Obtaining and Using an API Key
-
Request an API Key: To obtain an API key, please signup and proceed to your Developer Dashboard. Each key is uniquely associated with your environment (development or production).
-
Include the API Key in Requests: Use the
Authorization
header to include your API key in all API requests. The header format should be "Bearer BRITE_API_KEY
". ReplaceBRITE_API_KEY
with your actual API key or make use of environment variables. Here's an example using cURL:curl -L 'https://www.britelink.io/api/v1/drugs' -H 'Authorization: Bearer BRITE_API_KEY'
-
Key Security: Your API key should be kept confidential. Avoid exposing it in client-side code or public repositories. Securely store it, such as in environment variables.You can add this key in a .env for example
BRITE_API_KEY =secret**\*\*\*\*\***-\***\*-\*\***-\***\*-**\*\*\*\*\*\*
-
HTTPS Requirement: All API requests must be made over HTTPS. Unencrypted HTTP requests are not supported and will be rejected.Plain HTTP only works in local environment.
Example: Using the API Key in a JavaScript Application
const apiKey = process.env.BRITE_API_KEY;
const fetchData = async () => {
try {
const response = await axios.get("https://www.britelink.io/api/v1/drugs", {
headers: {
Authorization: `Bearer ${apiKey}`, // Correct header for authentication
},
});
console.log(response); // Process the response as needed
} catch (error) {
console.error("Error fetching data:", error);
}
};
Middleware Configuration
Our middleware is tailored to manage CORS (Cross-Origin Resource Sharing) and authentication headers. It is designed to accept the Authorization
header, following the Authorization: Bearer BRITE_API_KEY
format, for secure authentication.
Important Note for API Users
When making requests to our API, ensure you use the Authorization: Bearer YOUR_API_KEY
format. Incorrect header usage will result in authentication failure.
{
"success": false,
"error": "Must have a valid API key!"
}
Support
For assistance in obtaining an API key, please visit your Developer Dashboard or contact us.