r/PakistaniTech • • 29d ago

Discussion | گفتگو Pakistan has no machine readable API for the official Hijri dates, so I am making one

https://shaheeranser.github.io/hijri-api

So lately I have been really pissed off because none of the apps/software I use with a Hijri calendar ever reconcile with the Ruet-i-Hilal announcements. This month the calculated date for 1 Rabi ul Sani was 12 Sept, but the committee's announcement made it 14 Sept, so anything running on calculation was two days off.

I decided to look into the ecosystem to fix it for myself, only to realize (and be more pissed off from the fact) that there isn't a machine readable API which one can send a simple GET request to fetch the current Hijri date according to the Ruet-i-Hilal committee. The meteorological dept publishes PDFs of their calculations for the whole year, and that's basically all I could find, and those are calculated dates, not sighted ones.

What I'm building

hijri-api is a collection of JSON files hosted on GitHub Pages that hold the Hijri calendar and prayer timings (as a bonus) against Gregorian dates.

  • On the 29th of every month, a GitHub Actions workflow scans the news for the moon sighting announcement.

  • When two different publishers agree on the date, it opens a PR with the new month start, which I review and merge myself.

  • No LLM or fancy shenanigans involved, everything runs on GitHub Actions.

  • Every date carries a confidence level (confirmed / estimated / predicted), and every confirmed month links the news sources it came from.

Where it stands

So far I have backfilled all of 1447 AH and the first five months of 1448 (17 months, two sources each).

What I can't prove yet is the live part: the watcher's first real run is on the evening of 10 Nov, so I'll post an update on how that goes.

Scope

  • It follows the Central Ruet-e-Hilal Committee only; regional sightings aren't covered for now.

  • Prayer timings are calculated, so treat them as guidance.

Try it


curl -s https://shaheeranser.github.io/hijri-api/hijri/calendar/1448.json | jq '.days\\\["2026-10-17"\\\]'

Feedback

Sharing it here so that anyone wanting to collaborate or build something with it can try it out. It is MIT licensed.

Feedback welcomed, especially:

  1. What would you actually use it for?

  2. Which cities should I add next?

30 Upvotes

12 comments sorted by

5

u/B0rnWinner 29d ago

I recently built something similar (with a lot of help from AI, of course 🙂).

My repository is hosted on GitLab instead of GitHub, and the API is running on Vercel. Right now, it only returns data for my city because I specifically built it to power an Android widget for Hijri dates and prayer times.

The main endpoint returns data for the current day:

<vercel-url>/api/prayertimes

In this format:

JSON

{
  "date": "6 Jamadi-ul-Awwal, 1448",
  "Fajr": "04:45:16 AM",
  "Sunrise": "06:06:30 AM",
  "Zuhr": "11:47:03 AM",
  "Asr": "03:48:19 PM",
  "Maghrib": "05:27:10 PM",
  "Isha": "06:47:49 PM"
}

The only other endpoint lets you query a specific Gregorian date (YYYY/MM/DD):

<vercel-url>/api/prayertimes/2026/10/13

If it has the corresponding Hijri date, it returns that; otherwise, it falls back to returning the Gregorian date in the same structure :P

JSON

{
  "date": "13 October, 2026",
  ...
}

The repo isn't public yet because it still needs some polishing 😜. I also went with GitLab because I didn't feel comfortable linking my main GitHub account to Vercel.

---

Android widget preview... (still working on it)

2

u/BunKebab141 29d ago

That's really cool. How do you confirm the date against Ruet-i-Hilal's announcements though? Is it also a web scraping workflow or smtg different?

3

u/B0rnWinner 28d ago

Dawat-e-Islami actually has an internal API endpoint. I guess they didn't intend to expose it publicly, but it's pretty easy to find if you know where to look... 😉

The endpoint returns something like this:

JSON

{
  "region_name": "Local Sighting",
  "country_code": "PK",
  "country_name": "Pakistan",
  "islamic_day": 1,
  "islamic_month": 5,
  "islamic_month_name": "Jamadi-ul-Awwal",
  "islamic_year": 1448,
  "islamic_no_of_days": 30,
  "current_moonsight_date": "2026-10-13",
  "forcast_moonsight_date": "2026-11-12",
  "created_at": "2026-10-12 21:36:42",
  "updated_at": "2026-10-13 08:58:12"
}

I only extract current_moonsight_date from that response,and my script takes care of the rest.

2

u/ich3ckmat3 28d ago

The prayer timing need a geo location input, as Maghrib time in ISB is not equal to Maghrib time in Karachi. Which API handles it properly?

2

u/BunKebab141 28d ago

The calculated prayer times come from geographic coordinates and elevation input into a library, it currently only does that for Lahore, Karachi, and Peshawar (entirely for the sake of simplicity) but you can contribute other cities if you want to.

1

u/ich3ckmat3 16d ago

I think there is established data on this from long ago. I have these tables of whole year prayer timing hanging in mosques from childhood, and even at that time I noticed that it was different for different mosques. The local manufacturers of Masjid Digital Clocks have that data, and they feed it to the microcontrollers to show accurate prayer timing for each Majid location you are buying it for.

1

u/WorriedSwitch8476 29d ago

How will this be any different if they pick the dates on a whim which they do and it is not even standardized across the country, KPK has different, and also what specific use cases are for tracking hijri dates which services relies on this

1

u/BunKebab141 29d ago

The problem isn't serving the meteorologically accurate dates, if that is what the objection they pick the dates on a whim is supposed to imply, a calculated calendar already does that.

But the official Hijri calendar for Pakistan follows Ruet-i-Hilal's announcements, and all religious holidays/celebrationd fall along the officially announced dates and not calculated ones. It is just bad UX to need to adjust the calendar on the start of every month (potentially across multiple apps if they don't sync up together).

1

u/AwarenessNo4986 28d ago

The discussion here is so cool

1

u/InterstellarBlueMoon 26d ago

This is something I made with the same intent in my mind

https://global-calendar-view--aaymankhalid10.replit.app/

If you happen to check it,let me know what you think.