A small Cloudflare Worker that exposes plaintext endpoints for SGB prices and NPS NAV values.
GET /sgb/:symbolreturns the latest price for any official SGB symbol.GET /nps/:schemereturns the latest NAV for any official NPS scheme code or a readable alias.
Every SGB in the exchange catalogue is supported by its official symbol. For example:
https://<your-worker>/sgb/SGBSEP29VIhttps://<your-worker>/sgb/SGBJUN31I
Symbols are case-insensitive but must be supplied in their official compact form, without hyphens. For example, use /sgb/SGBSEP29VI. This matches the NPS route: pass the official identifier directly rather than relying on a maintained list.
Every scheme in the NPS catalogue is supported by its official scheme code. This removes the need to add a code change whenever the catalogue changes.
For example, these equivalent URLs return HDFC Scheme E - Tier I:
https://<your-worker>/nps/SM008001https://<your-worker>/nps/hdfc-e-tier-1
The official scheme-code format is SM followed by six digits. It is case-insensitive, so /nps/sm008001 also works. Find scheme codes in the official Protean NPS NAV search.
The common HDFC options retain convenient aliases with unambiguous tier names:
hdfc-e-tier-1,hdfc-c-tier-1,hdfc-g-tier-1hdfc-e-tier-2,hdfc-c-tier-2,hdfc-g-tier-2hdfc-equity-advantage-tier-1
=IMPORTDATA("https://nps-sgb-api.vsvipul.workers.dev/nps/"&E236)
Set E236 to an official NPS scheme code such as SM008001.
- SGB responses:
max-age=300 - NPS responses:
max-age=86400
The Worker also keeps successful responses in Cloudflare's Worker Cache API, avoiding repeat upstream requests from the same Cloudflare location. If an upstream temporarily fails, it can return the last successful result with X-Data-Stale: true for up to one day.
For cache hits that bypass Worker execution entirely, configure a Cloudflare Cache Rule for the Worker domain:
/sgb/*: cache200responses for 300 seconds/nps/*: cache200responses for 86400 seconds4xxand5xx: do not cache
npm install
npm run devnpx wrangler deploy