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.io

One 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

ParameterDefaultValues
latituderequiredDecimal degrees, -90 to 90
longituderequiredDecimal degrees, -180 to 180
daterequiredYYYY-MM-DD
methodMWLAny code from the methods list below
schoolSTANDARDSTANDARD (Shafi, Maliki, Hanbali) or HANAFI. Changes Asr.
timezoneUTCIANA name, e.g. Asia/Dubai. Always send it; the API cannot infer it from coordinates.
latitudeAdjustmentANGLE_BASEDANGLE_BASED, MIDDLE_OF_THE_NIGHT, ONE_SEVENTH, NONE. High-latitude correction for Fajr and Isha.
midnightModeSTANDARDSTANDARD (sunset to sunrise) or JAFARI (sunset to Fajr)
format24h24h, 12h, 12hNS, Float, iso8601
shafaqgeneralgeneral, 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 included

Run 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?)
ParameterDefaultDescription
method"MWL"One of the 24 method codes
school"STANDARD""STANDARD" or "HANAFI"
asrShadowFactornullCustom Asr shadow multiplier, overrides school

getTimes()

pt.getTimes(date, latitude, longitude, elevation?, latitudeAdjustment?, midnightMode?, format?, timezone?)
ParameterDefaultDescription
daterequiredJavaScript Date
latitude, longituderequirednumber or numeric string
elevationnullMetres above sea level
latitudeAdjustment"ANGLE_BASED""ANGLE_BASED", "MIDDLE_OF_THE_NIGHT", "ONE_SEVENTH", "NONE"
midnightModenull"STANDARD" or "JAFARI"
format"24h""24h", "12h", "12hNS", "Float", "iso8601"
timezonenullIANA 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

FormatExample
"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

tune()Per-prayer minute offsets: pt.tune({ Fajr: 2, Isha: -3 })
setShafaq()Twilight for Moonsighting Isha: SHAFAQ_GENERAL, SHAFAQ_AHMER (red), SHAFAQ_ABYAD (white)
setCustomMethod()Your own angles with method "CUSTOM": 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 npm

24 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, London
MAKKAHUmm Al-Qura University, Makkah
ISNAIslamic Society of North America
EGYPTEgyptian General Authority of Survey
KARACHIUniversity of Islamic Sciences, Karachi
TEHRANInstitute of Geophysics, University of Tehran
JAFARILeva Institute, Qum
GULFGulf Region
KUWAITKuwait
QATARQatar
DUBAIDubai (experimental)
JORDANMinistry of Awqaf, Islamic Affairs and Holy Places
TURKEYDiyanet İşleri Başkanlığı (experimental)
RUSSIASpiritual Administration of Muslims of Russia
FRANCEUnion des Organisations Islamiques de France
PORTUGALComunidade Islâmica de Lisboa
SINGAPOREMajlis Ugama Islam Singapura
JAKIMJabatan Kemajuan Islam Malaysia
KEMENAGKementerian Agama Republik Indonesia
TUNISIAMinistry of Religious Affairs, Tunisia
ALGERIAMinistry of Religious Affairs, Algeria
MOROCCOMinistry of Habous and Islamic Affairs
MOONSIGHTINGMoonsighting 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