Indian Stock Market API in Node.js: fetch Examples for Quotes, Prices and Financials
Node.js 20+ ships fetch, so no HTTP library is needed. Send your key in the X-API-Key header. (There is also an official bharatstock npm package with TypeScript types.)
const API = "https://bharatstockapi.com";
const headers = { "X-API-Key": process.env.BHARATSTOCK_API_KEY };
async function get(path, params = {}) {
const url = new URL(API + path);
for (const [k, v] of Object.entries(params)) url.searchParams.set(k, v);
const res = await fetch(url, { headers });
if (res.status === 429) {
throw new Error(`Daily limit reached; resets in ${res.headers.get("retry-after")}s`);
}
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.json();
}
const quotes = await get("/v1/stocks/quotes", { symbols: "RELIANCE,TCS,INFY" });
const prices = await get("/v1/stocks/RELIANCE/prices", { from: "2026-01-01", page_size: 100 });
const fin = await get("/v1/stocks/RELIANCE/financials", { period_type: "annual" });
console.log(quotes, prices.data[0], fin.data[0].fiscal_year);Run it as an ES module (.mjs) for top-level await. Keep the key in an environment variable, never in client-side code. For limits see handling 429s.