REST API
PrayCalc exposes a free public REST API for prayer time calculations, location lookup, and calendar export. All endpoints accept GET requests and return JSON (or text/calendar for the ICS endpoint).
Base URL
https://praycalc.com/api
These are same-origin endpoints for the praycalc.com web app (mobile, desktop, and the calendar export flow). There is no Access-Control-Allow-Origin header, so browser fetch/XMLHttpRequest calls from a different origin will be blocked by CORS — server-to-server calls (curl, backend jobs) are unaffected.
There is no API key, authentication, or rate limiting on any endpoint.
Prayer times
Calculate prayer times for a date range at any coordinate.
GET /api/prayers?lat={lat}&lng={lng}&tz={tz}&from={date}&to={date}&hanafi={0|1}&method={id}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
lat | float | Yes | Latitude |
lng | float | Yes | Longitude |
tz | string | No | IANA timezone name (e.g., America/New_York). Defaults to UTC |
from | string | Yes | Start date in YYYY-MM-DD format |
to | string | Yes | End date in YYYY-MM-DD format |
hanafi | 0 or 1 | No | Use Hanafi Asr calculation. Defaults to 0 (Shafi’i) |
method | string | No | Calculation method id. Defaults to PrayCalc’s dynamic method (DPC) when omitted. One of DPC, UOIF, ISNACA, ISNA, SAMR, IGUT, MWL, DIBT, Karachi, Kuwait, UAQ, Qatar, Egypt, MUIS, MSC |
Response
A bare JSON array — one entry per day in the range, not wrapped in a { "days": [...] } object:
[
{
"date": "2026-07-10",
"prayers": {
"Fajr": "03:48:18",
"Sunrise": "05:34:03",
"Dhuhr": "13:03:57",
"Asr": "17:00:37",
"Maghrib": "20:28:56",
"Isha": "21:43:38",
"Qiyam": "01:46:45"
}
}
]
prayers always includes Qiyam (last third of the night) in addition to the five daily prayers and Sunrise.
Notes
- Maximum date range: 400 days
- Times use the NREL SPA algorithm (solar position to 0.0003 degree accuracy)
- Cache:
public, max-age=3600 - An unrecognized
methodvalue returns400with the list of valid ids in the error message
Example
curl "https://praycalc.com/api/prayers?lat=40.7128&lng=-74.006&tz=America/New_York&from=2026-07-10&to=2026-07-10"
Geolocation
Look up location details by coordinates, place name, or client IP.
GET /api/geo?lat={lat}&lng={lng}
GET /api/geo?q={query}
GET /api/geo?ip=1
Parameters
Use one of the three modes:
| Mode | Parameters | Description |
|---|---|---|
| Coordinates | lat + lng | Reverse geocode a lat/lng pair |
| Name lookup | q (min 2 chars) | Look up a place by name |
| IP detection | ip=1 | Detect the client’s IP (or Vercel’s edge geo headers) and geolocate it |
Response
{
"lat": 40.71427,
"lng": -74.00597,
"displayName": "New York, NY",
"city": "New York",
"state": "ny",
"country": "us",
"slug": "us/ny/new-york",
"timezone": "America/New_York"
}
state and country are lowercase two-letter codes (US state abbreviation / ISO country code), not full names. slug is the path PrayCalc uses for that location’s shareable URL (e.g. praycalc.com/us/ny/new-york).
On a miss (no match, private/unresolvable IP, or missing params), the endpoint returns HTTP 200 with a JSON null body — never 404.
Location search
Autocomplete search across cities worldwide.
GET /api/search?q={query}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
q | string | Yes | Search query (minimum 2 characters) |
Response
Returns an array of matching locations in the same shape as /api/geo, ordered by population:
[
{
"lat": 51.50853,
"lng": -0.12574,
"displayName": "London, GB",
"city": "London",
"state": "gb",
"country": "gb",
"slug": "gb/london",
"timezone": "Europe/London"
}
]
Returns an empty array ([]) if the query is under 2 characters or no results are found.
Calendar export (ICS)
Generate a subscribable iCalendar feed — one event per prayer per day.
GET /api/calendar.ics?lat={lat}&lng={lng}&tz={tz}&days={n}&hanafi={0|1}&events={0|1}
There is no PDF calendar endpoint — /api/calendar/pdf does not exist (404). PDF export, if offered, is a client-side feature of the web app, not a REST endpoint.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
lat | float | Yes | Latitude |
lng | float | Yes | Longitude |
tz | string | No | IANA timezone name. Defaults to UTC |
days | integer | No | Number of days to export, 1-365. Defaults to 30 |
hanafi | 0 or 1 | No | Use Hanafi Asr calculation. Defaults to 0 (Shafi’i) |
events | 0 or 1 | No | Include all-day events for fixed Islamic observances (Ramadan start, both Eids, Ashura, Islamic New Year, Laylat al-Qadr, Isra & Mi’raj). Defaults to 0 (off) |
Response
Returns an RFC 5545 .ics file:
Content-Type: text/calendar; charset=utf-8
Content-Disposition: attachment; filename="prayer-times-<tz>.ics"
Example
curl -o calendar.ics "https://praycalc.com/api/calendar.ics?lat=40.7128&lng=-74.006&tz=America/New_York&days=30"
Error responses
Errors return a JSON body with just an error string — there is no status field in the body (the status is only in the HTTP response code):
{
"error": "Missing or invalid params"
}
| Status | Meaning |
|---|---|
400 | Invalid or missing parameters (bad coordinates, dates, timezone, or method) |
/api/geo and /api/search do not return 404 for a miss — see their sections above.