← All posts

July 19, 2026

I built a free API for Pakistani mutual fund NAVs (because MUFAP's own one doesn't work)

open sourcefintechpakistanapi
A free API for Pakistani mutual fund NAVs

Why MUFAP's own API doesn't work

I needed daily NAV (net asset value) data for every Pakistani mutual fund for Gramafin, the personal finance app I've been building. The obvious place to get it is MUFAP — the Mutual Funds Association of Pakistan, the actual industry body that every asset management company reports to. They even have what looks like a JSON API behind their fund directory page.

It doesn't work. Or rather, it doesn't work for anyone who isn't a browser. I tried hitting their endpoints with headers copied byte-for-byte from a real Chrome request — same User-Agent, same Accept headers, same everything — and got a 500 every time. My best guess is there's some session or anti-forgery token their own frontend JS sets up that isn't practical to replicate from a plain server-side request. I didn't chase it further than that.

Their public Fund Directory page does work, though. It's a plain, server-rendered HTML table: every one of MUFAP's 500+ funds, with current NAV and offer price sitting right there in the markup. No auth wall, no pagination, no JavaScript required to see it. So instead of fighting their broken API, I scrape the page that already has the data.

To be fair, there is a paid option

I should be clear that this isn't a total void. CapitalStake sells a Pakistani mutual funds data product, and it's substantially more comprehensive than what I built — AUMs, AMC breakdowns, sector allocations, top and quarterly holdings, payouts, and full NAV history, delivered over REST, WebSocket, CSV, or Excel, with an uptime SLA behind it.

It's also a commercial product with a "request a consultation" button where the pricing usually goes. That's a perfectly reasonable business — maintaining that depth of data costs real money, and if you need holdings history, sector allocation, and a 99.99% uptime guarantee, you should go and pay them for it. I'm not pretending this repo competes with that.

But most of the time you don't need any of that. You need today's NAV for 531 funds, as JSON, without a sales call or a recurring invoice. That's the gap this fills. And because it's MIT-licensed, the next person with the same narrow need doesn't have to rebuild it — or budget for it — either.

Turning it into its own thing

This started as a small piece of Gramafin's backend — a scraper, a Redis cache, a cron job. But scraping MUFAP isn't really a Gramafin-specific problem. Anyone building anything in the Pakistani fintech space — a budgeting app, a robo-advisor, a research tool — runs into the exact same wall. So I pulled the logic out into its own thing: pakistan-mutual-funds-api, free and open source on GitHub.

The pakistan-mutual-funds-api repository on GitHub

It's deliberately boring technology — no database to set up, no cloud account to configure, no framework to learn. Clone it, npm install, run it. That's the whole ask.

What it actually does

Three small pieces, each doing one thing:

  • Scrapes MUFAP's Fund Directory with cheerio, pulling fund name, AMC, NAV, offer price, and category for every fund listed.
  • Stores the result as a plain JSON file on disk. No Postgres, no Redis, no ceremony — if you can read a JSON file, you can run this.
  • Serves it over a small Express API, GET /api/funds, CORS wide open so you can call it straight from frontend JS.

The only configuration that actually matters is how often it re-scrapes. MUFAP publishes updated NAVs once per business day — they don't move intraday — so the default is once a day, skipping weekends. You can dial that up or down with one environment variable, or turn the built-in scheduler off entirely and trigger scrapes from your own cron if you're deploying this somewhere serverless.

Here's what a real response looks like (this is live data, not a mockup):

A real response from GET /api/funds showing live NAV data for Pakistani mutual funds

Try it

bash
git clone https://github.com/saadsalmankhan/pakistan-mutual-funds-api.git
cd pakistan-mutual-funds-api
npm install
cp .env.example .env
npm run dev

That's it — it scrapes once on startup and starts serving at localhost:4000/api/funds. Full config options and API reference are in the README.

If you build something with it, or run into MUFAP changing their page markup and breaking the scraper (it'll happen eventually), open an issue. It's MIT-licensed — use it, fork it, fix it.

Share this post

Get new posts by email

Occasional writing on payments, fintech, and building products. No spam, unsubscribe anytime.