Prayer times, as an API and a package
One TypeScript engine, ported from the Islamic Network PHP libraries, exposed two ways. No API key. GPL-3.0.
REST API
https://api.praytime.ioOne endpoint. Pass a location, a date and the IANA timezone, get all eleven times back with the method metadata. Without a timezone the times come back in UTC. No API key. CORS is open, so you can call it from the browser.
GET /v1/times?latitude=25.2&longitude=55.27&date=2026-09-19&timezone=Asia/Dubai&method=GULF
{
"times": {
"Imsak": "04:40", "Fajr": "04:50", "Sunrise": "06:06", "Dhuhr": "12:13",
"Asr": "15:40", "Sunset": "18:19", "Maghrib": "18:19", "Isha": "19:31",
"Midnight": "00:13", "Firstthird": "22:15", "Lastthird": "02:10"
},
"meta": {
"latitude": 25.2, "longitude": 55.27, "timezone": "Asia/Dubai",
"method": { "id": 8, "name": "Gulf Region", "params": { "Fajr": 19.5, "Isha": "90 min" } },
"latitudeAdjustmentMethod": "ANGLE_BASED", "midnightMode": "STANDARD",
"school": "STANDARD", "offset": {}
}
}Query parameters
| Parameter | Default | Values |
|---|---|---|
| latitude | required | Decimal degrees, -90 to 90 |
| longitude | required | Decimal degrees, -180 to 180 |
| date | required | YYYY-MM-DD |
| method | MWL | Any code from the methods list below |
| school | STANDARD | STANDARD (Shafi, Maliki, Hanbali) or HANAFI. Changes Asr. |
| timezone | UTC | IANA name, e.g. Asia/Dubai. Always send it; the API cannot infer it from coordinates. |
| latitudeAdjustment | ANGLE_BASED | ANGLE_BASED, MIDDLE_OF_THE_NIGHT, ONE_SEVENTH, NONE. High-latitude correction for Fajr and Isha. |
| midnightMode | STANDARD | STANDARD (sunset to sunrise) or JAFARI (sunset to Fajr) |
| format | 24h | 24h, 12h, 12hNS, Float, iso8601 |
| shafaq | general | general, ahmer, abyad. Moonsighting method only. |
Errors
Invalid input returns 400 with a message per field. Anything else is a 5xx and safe to retry.
{ "error": { "date": ["must be YYYY-MM-DD"] } }Health
GET /health → { "status": "ok" }OpenAPI 3 specification npm package
@praytime/core · ESM + CJS · TypeScript types includedRun the calculation locally. Zero runtime dependencies. Works in Node, Bun, Deno and the browser. Published from GitHub Actions with npm provenance.
npm install @praytime/core
import { PrayerTimes } from "@praytime/core";
const pt = new PrayerTimes("GULF", "STANDARD");
const times = pt.getTimes(new Date(), 25.2, 55.27, null, "ANGLE_BASED", null, "24h", "Asia/Dubai");
times.Fajr; // "04:50"
times.Maghrib; // "18:19"Constructor
new PrayerTimes(method?, school?, asrShadowFactor?)
| Parameter | Default | Description |
|---|---|---|
| method | "MWL" | One of the 24 method codes |
| school | "STANDARD" | "STANDARD" or "HANAFI" |
| asrShadowFactor | null | Custom Asr shadow multiplier, overrides school |
getTimes()
pt.getTimes(date, latitude, longitude, elevation?, latitudeAdjustment?, midnightMode?, format?, timezone?)
| Parameter | Default | Description |
|---|---|---|
| date | required | JavaScript Date |
| latitude, longitude | required | number or numeric string |
| elevation | null | Metres above sea level |
| latitudeAdjustment | "ANGLE_BASED" | "ANGLE_BASED", "MIDDLE_OF_THE_NIGHT", "ONE_SEVENTH", "NONE" |
| midnightMode | null | "STANDARD" or "JAFARI" |
| format | "24h" | "24h", "12h", "12hNS", "Float", "iso8601" |
| timezone | null | IANA name. Falls back to the host timezone. |
Returns an object with Imsak, Fajr, Sunrise, Dhuhr, Asr, Sunset, Maghrib, Isha, Midnight, Firstthird and Lastthird.
Output formats
| Format | Example |
|---|---|
| "24h" | "04:30" |
| "12h" | "4:30 am" |
| "12hNS" | "4:30" (no suffix) |
| "Float" | 4.5 (decimal hours) |
| "iso8601" | "2024-04-24T04:30:00+01:00" |
More
pt.tune({ Fajr: 2, Isha: -3 })CustomMethod({ Fajr: 18, Isha: 17 })import { PrayerTimes, SHAFAQ_AHMER, CustomMethod } from "@praytime/core";
const moon = new PrayerTimes("MOONSIGHTING");
moon.setShafaq(SHAFAQ_AHMER);
const own = new PrayerTimes("CUSTOM");
own.setCustomMethod(CustomMethod({ Fajr: 18, Isha: 17 }));
own.tune({ Fajr: 2, Isha: -3 });Also exported: getMethods(), getMethodCodes(), the DMath helpers, and the types CalculationMethod, School, MidnightMode, LatitudeAdjustment, TimeFormat, PrayerTimesResult, TuneOffsets and CalculationMeta.
@praytime/core on npm24 calculation methods
Same codes in the API and the package. Includes the Moonsighting Committee model for Fajr and Isha, and CUSTOM for your own angles in the package.
MWLMuslim World League, LondonMAKKAHUmm Al-Qura University, MakkahISNAIslamic Society of North AmericaEGYPTEgyptian General Authority of SurveyKARACHIUniversity of Islamic Sciences, KarachiTEHRANInstitute of Geophysics, University of TehranJAFARILeva Institute, QumGULFGulf RegionKUWAITKuwaitQATARQatarDUBAIDubai (experimental)JORDANMinistry of Awqaf, Islamic Affairs and Holy PlacesTURKEYDiyanet İşleri Başkanlığı (experimental)RUSSIASpiritual Administration of Muslims of RussiaFRANCEUnion des Organisations Islamiques de FrancePORTUGALComunidade Islâmica de LisboaSINGAPOREMajlis Ugama Islam SingapuraJAKIMJabatan Kemajuan Islam MalaysiaKEMENAGKementerian Agama Republik IndonesiaTUNISIAMinistry of Religious Affairs, TunisiaALGERIAMinistry of Religious Affairs, AlgeriaMOROCCOMinistry of Habous and Islamic AffairsMOONSIGHTINGMoonsighting Committee Worldwide (moonsighting.com)CUSTOMUser-defined Fajr and Isha angles (package only)Source and licence
GPL-3.0-or-later. TypeScript rewrite of the Islamic Network PHP libraries, which port Hamid Zarrabi-Zadeh's praytimes.org. Moonsighting model by Syed Khalid Shaukat. Issues and pull requests on GitHub.
github.com/dwekat/praytime