Authentication
AuthenticationCopied!
Quartr API offers a secure and convenient way to authenticate requests using API keys. This method prioritizes security and efficiency by eliminating the need to embed account credentials directly in your code.
Note that we've deprecated the previous HTTP Basic Auth method in favor of API key authentication.
API Key Generation
The easiest and recommended way to generate and manage keys is by logging in to the Quartr API Portal and using the provided methods to create, copy and delete API Keys from the “API Keys”-section of the Portal.
API keys can also be generated by making a POST request to the /auth/generate-api-key endpoint. This request must include your Quartr username and password in the request body, along with an optional validityPeriod parameter to set the validity period of the key in days (default is 90 days).
Here's a brief example of how to generate an API key:
const axios = require('axios');
const username = 'username'; // replace with your username
const password = 'password'; // replace with your password
const validityPeriod = 45; // set the validity period in days
axios.post(`https://api.quartr.com/public/v1/auth/generate-api-key`,
{ username, password, validityPeriod },
)
.then(response => {
console.log(apiKeyData);
})
.catch(error => console.log(error));
The response from the server will include your new API key and its validity period:
{
"apiKey": "4ece3c8b1ce6a15226945fcd400b8d8076e5cfe2138da3079ac2644b6b383ea1",
"validTo": "2023-11-13T17:48:26.999Z"
}
API Key Usage
To use your API key for authentication, include it in the headers of your API requests:
const apiKey = "api_key"; // Replace with you api key
const ticker = "AAPL";
const eventType = 'all';
const country = 'US';
axios.get(`https://api.quartr.com/public/v1/companies/ticker/${ticker}/`, {
headers: { 'X-API-KEY': apiKey },
params: { eventType, country }
})
.then(response => {
console.log(response.data);
})
.catch(error => console.log(error));
API Key Management
You can manage your API keys (view all keys and delete specific keys) on the Quartr API Portal “API Keys”-section or by using the /auth/api-keys and /auth/api-key/{apiKeyId} endpoints respectively. For detailed instructions on how to use these endpoints, please refer to the Quartr API Reference Documentation.
Basic Auth Deprecation Notice
Important: As of July 2023, the HTTP Basic Auth method is deprecated and will no longer be supported in future versions of the Quartr API. We strongly encourage all users to transition to using API keys for authentication as soon as possible. For assistance with this transition, please contact our support team.