Getting headers response Nodejs API client

Hey guys, I would like to read the X-HubSpot-RateLimit-Daily header. Do you know if I can do this using the nodejs client? I know I can use axios instead but before changing all my API calls I would like to know if I can avoid that.

Hello @ACarr3
retrieve the X-HubSpot-RateLimit-Daily header using the Node.js HTTP/HTTPS module.
Here’s an example:

const https = require('https');

const options = {
 hostname: 'api.hubapi.com',
 path: '/contacts/v1/lists/all/contacts/all',
 headers: {
 'Authorization': 'Bearer <your access token>',
 'Accept': 'application/json'
 }
};

https.get(options, (res) => {
 const dailyRateLimit = res.headers['x-hubspot-ratelimit-daily'];
 console.log(`X-HubSpot-RateLimit-Daily: ${dailyRateLimit}`);
});

In this example, we make a GET request to the HubSpot Contacts API and retrieve the daily rate limit from the response headers. You’ll need to replace <your access token> with your HubSpot API access token.

Note that if you’re making a large number of API calls, you may want to consider using a library like Axios to handle HTTP requests, as it provides more features and is easier to use than the built-in HTTP/HTTPS module.

Thanks & Regards
Himanshu Rauthan