Skip to content

Instantly share code, notes, and snippets.

@vahidshaik1901
Created August 22, 2026 10:12
Show Gist options
  • Select an option

  • Save vahidshaik1901/593fd3a3d6e54ccfb189c91e6f8e1b63 to your computer and use it in GitHub Desktop.

Select an option

Save vahidshaik1901/593fd3a3d6e54ccfb189c91e6f8e1b63 to your computer and use it in GitHub Desktop.
Free prayer times API (adhan / salah / namaz timings) — no API key, CORS open. Each country served its own official calculation method. JSON + iCal. https://waqtazan.com

Free Prayer Times API — وقت أذان (Waqtazan)

A free, public JSON API for Islamic prayer times (salah / namaz timings), adhan times, qibla direction, and iCal calendar feeds.

No API key. No sign-up. No quota to babysit. Access-Control-Allow-Origin: *, so you can call it straight from the browser.

Base URL: https://waqtazan.com/api/v1


Why another prayer times API?

Most prayer-time APIs run one calculation method worldwide and make you override it with a query parameter — which means you need to already know the right answer.

This one ships the method each country's own religious authority actually publishes, as the default:

Country Method served by default
🇸🇦 Saudi Arabia Umm al-Qura — Isha = Maghrib + 90 min, and +120 during Ramadan
🇪🇬 Egypt Egyptian General Authority for Survey
🇹🇷 Turkey Diyanet İşleri Başkanlığı (asr-ı evvel, the first-shadow asr)
🇵🇰 Pakistan University of Islamic Sciences, Karachi + Hanafi asr
🇮🇩 Indonesia Kemenag, including the official ihtiyat minutes
🇲🇾 Malaysia JAKIM (times are gazetted per zone)
🇮🇷 Iran Institute of Geophysics, Tehran — Jafari maghrib (sunset + redness)
🇦🇪 🇰🇼 🇶🇦 🇧🇭 🇮🇶 🇴🇲 🇯🇴 🇲🇦 🇩🇿 🇹🇳 … each fitted to that country's official published calendar

Ramadan is handled automatically where the convention changes.

Where no official source is reachable, the site says so on the page rather than claiming an authority it doesn't have.


1. Prayer times for a city

GET /api/v1/timings/{country}/{city}
GET /api/v1/timings/{country}/{city}?date=YYYY-MM-DD
curl https://waqtazan.com/api/v1/timings/saudi-arabia/riyadh
{
  "city": { "slug": "riyadh", "name_ar": "الرياض", "name_en": "Riyadh" },
  "country": "saudi-arabia",
  "date": "2026-08-22",
  "hijri": "9 ربيع الأول 1448 هـ",
  "isRamadan": false,
  "times": {
    "fajr": "4:08 ص",
    "sunrise": "5:30 ص",
    "dhuhr": "11:56 ص",
    "asr": "3:24 م",
    "maghrib": "6:21 م",
    "isha": "7:51 م"
  },
  "timesISO": {
    "fajr": "2026-08-22T01:08:00.000Z",
    "sunrise": "2026-08-22T02:30:00.000Z",
    "dhuhr": "2026-08-22T08:56:00.000Z",
    "asr": "2026-08-22T12:24:00.000Z",
    "maghrib": "2026-08-22T15:21:00.000Z",
    "isha": "2026-08-22T16:51:00.000Z"
  },
  "method": "umm_al_qura",
  "source": "https://waqtazan.com"
}

Two time formats on purpose:

  • times — ready to print, Arabic locale, Latin digits (ص = AM, م = PM)
  • timesISO — true UTC instants, for countdowns, alarms, and date maths

sunrise is included but it is not a prayer — there is no adhan at sunrise. It is there because Fajr ends at sunrise.

A few real endpoints

curl https://waqtazan.com/api/v1/timings/egypt/cairo            # مواقيت الصلاة في القاهرة
curl https://waqtazan.com/api/v1/timings/saudi-arabia/makkah    # مكة المكرمة
curl https://waqtazan.com/api/v1/timings/saudi-arabia/madinah   # المدينة المنورة
curl https://waqtazan.com/api/v1/timings/turkey/istanbul        # İstanbul namaz vakitleri
curl https://waqtazan.com/api/v1/timings/pakistan/karachi       # Karachi namaz timings
curl https://waqtazan.com/api/v1/timings/indonesia/jakarta      # jadwal sholat Jakarta

City and country slugs are Latin and stable. They never change with locale.


2. Find a city

GET /api/v1/search?q={arabic, english, or slug}
curl "https://waqtazan.com/api/v1/search?q=makkah"
curl "https://waqtazan.com/api/v1/search?q=%D8%A7%D9%84%D8%B1%D9%8A%D8%A7%D8%B6"   # الرياض
{ "results": [ { "type": "city", "slug": "makkah", "name_ar": "مكة المكرمة",
                 "country_slug": "saudi-arabia", "country_ar": "السعودية", "iso2": "SA" } ] }

Matches Arabic names, English names, and slugs. Countries come back first, then cities ranked by population.


3. Nearest city to a coordinate

GET /api/v1/nearest?lat={lat}&lng={lng}
curl "https://waqtazan.com/api/v1/nearest?lat=30.0444&lng=31.2357"
{ "country": "egypt", "city": "cairo", "name_ar": "القاهرة" }

Pair it with navigator.geolocation to get prayer times for wherever the user is. Ranking is great-circle distance, and it wraps correctly at the antimeridian.


4. Calendar feed (iCal / .ics)

GET /api/v1/ical/{country}/{city}.ics
curl https://waqtazan.com/api/v1/ical/pakistan/karachi.ics

Returns the current month as a VCALENDAR, one VEVENT per adhan — five a day. Subscribe to it in Apple Calendar, Google Calendar, or Outlook and the times land in your normal calendar.


How the times are produced

Times are computed from astronomy on every request, from the city's real coordinates. They are never stored in a database, so they can never go stale, and there is no nightly job that can silently fail.

A build is blocked from shipping if any computed time drifts more than two minutes from its reference fixtures — including rows hand-entered off official national calendars.


Fair use

It is free and there is no key. Please be reasonable:

  • Cache on your side for the day. Times for a given city and date never change.
  • Don't poll every second. Fetch once, then count down locally from timesISO.
  • A credit link is appreciated but not required: التوقيت من وقت أذان / "Times by Waqtazan" → https://waqtazan.com

Found a wrong time?

Prayer times are a trust, not a feature. If a time disagrees with your local mosque or your national calendar, report it and it will be checked: info@waqtazan.com


Site: https://waqtazan.com · Arabic-first, one page per city, with qibla direction, prayer end times, the three forbidden windows (أوقات النهي), and a printable monthly table.

#!/usr/bin/env bash
# Free prayer times API — curl recipes. https://waqtazan.com
# No API key needed. Requires: curl, jq
API="https://waqtazan.com/api/v1"
# --- Today's prayer times, pretty printed -----------------------------------
curl -s "$API/timings/saudi-arabia/riyadh" | jq '.times'
# {
# "fajr": "4:08 ص", "sunrise": "5:30 ص", "dhuhr": "11:56 ص",
# "asr": "3:24 م", "maghrib": "6:21 م", "isha": "7:51 م"
# }
# --- Just one prayer --------------------------------------------------------
curl -s "$API/timings/egypt/cairo" | jq -r '.times.maghrib' # iftar time
# --- A specific date (e.g. the first day of Ramadan 1448) -------------------
curl -s "$API/timings/saudi-arabia/makkah?date=2027-02-08" | jq '{date, hijri, isRamadan, times}'
# --- Which city am I near? --------------------------------------------------
curl -s "$API/nearest?lat=24.7136&lng=46.6753" | jq
# { "country": "saudi-arabia", "city": "riyadh", "name_ar": "الرياض" }
# --- Search for a city (Arabic, English, or slug) ---------------------------
curl -s "$API/search?q=lahore" | jq '.results[] | {slug, name_ar, country_slug}'
# --- Geolocate, then get times, in one line ---------------------------------
LAT=41.0138; LNG=28.9497 # Istanbul
read -r COUNTRY CITY <<< "$(curl -s "$API/nearest?lat=$LAT&lng=$LNG" | jq -r '.country + " " + .city')"
curl -s "$API/timings/$COUNTRY/$CITY" | jq '{city: .city.name_en, method, times}'
# --- Subscribe to a month of adhan times in your calendar -------------------
curl -s "$API/ical/pakistan/karachi.ics" -o karachi-prayer-times.ics
# then: open karachi-prayer-times.ics
# --- Cache politely: times for a city+date never change ---------------------
# Fetch once per day, not once per second.
CACHE="/tmp/prayer-$(date +%F).json"
[ -f "$CACHE" ] || curl -s "$API/timings/turkey/istanbul" -o "$CACHE"
jq -r '.times | to_entries[] | "\(.key)\t\(.value)"' "$CACHE"
/**
* Free prayer times API — JavaScript example. https://waqtazan.com
*
* Works in the browser (CORS is open) and in Node 18+.
* No API key, no sign-up.
*
* node example-node.js
*/
const API = 'https://waqtazan.com/api/v1'
// sunrise ships in the payload because Fajr ends at sunrise — it is not an adhan
const ADHANS = ['fajr', 'dhuhr', 'asr', 'maghrib', 'isha']
/** Today's prayer times, or any date as YYYY-MM-DD. */
export async function getTimings(country, city, date) {
const q = date ? `?date=${date}` : ''
const res = await fetch(`${API}/timings/${country}/${city}${q}`)
if (!res.ok) throw new Error(`prayer times: HTTP ${res.status}`)
return res.json()
}
/** Nearest city to a coordinate. */
export async function getNearest(lat, lng) {
const res = await fetch(`${API}/nearest?lat=${lat}&lng=${lng}`)
if (!res.ok) throw new Error(`nearest: HTTP ${res.status}`)
return res.json()
}
/** Search cities by Arabic name, English name, or slug. */
export async function searchCities(q) {
const res = await fetch(`${API}/search?q=${encodeURIComponent(q)}`)
if (!res.ok) throw new Error(`search: HTTP ${res.status}`)
return (await res.json()).results
}
/** The next adhan and how long until it, from the ISO instants. */
export function nextAdhan(day, now = Date.now()) {
for (const name of ADHANS) {
const at = new Date(day.timesISO[name]).getTime()
if (at > now) return { name, at, msRemaining: at - now }
}
return null // Isha has passed; fetch tomorrow for the next Fajr
}
export const formatRemaining = (ms) => {
const s = Math.max(0, Math.floor(ms / 1000))
const pad = (n) => String(n).padStart(2, '0')
return `${pad(Math.floor(s / 3600))}:${pad(Math.floor(s / 60) % 60)}:${pad(s % 60)}`
}
/* ---------------------------------------------------------------------------
* Browser: prayer times for wherever the visitor is
* ------------------------------------------------------------------------ */
export function timesForMyLocation() {
return new Promise((resolve, reject) => {
if (!navigator.geolocation) return reject(new Error('no geolocation'))
navigator.geolocation.getCurrentPosition(async (pos) => {
const { country, city } = await getNearest(pos.coords.latitude, pos.coords.longitude)
resolve(await getTimings(country, city))
}, reject, { timeout: 8000 })
})
}
/* ---------------------------------------------------------------------------
* Demo
* ------------------------------------------------------------------------ */
async function main() {
const day = await getTimings('saudi-arabia', 'riyadh')
console.log(`\n ${day.city.name_ar} · ${day.city.name_en}`)
console.log(` ${day.date} ${day.hijri}`)
console.log(` method: ${day.method}${day.isRamadan ? ' · Ramadan' : ''}\n`)
for (const [name, value] of Object.entries(day.times)) {
console.log(` ${ADHANS.includes(name) ? ' ' : '·'} ${name.padEnd(8)} ${value}`)
}
const next = nextAdhan(day)
console.log(
next
? `\n Next: ${next.name} in ${formatRemaining(next.msRemaining)}\n`
: `\n Isha has passed — tomorrow's Fajr is next.\n`,
)
// Cache on your side: times for a given city and date never change.
// Fetch once a day and count down locally from timesISO.
}
if (import.meta.url === `file://${process.argv[1]}`) main()
#!/usr/bin/env python3
"""
Free prayer times API — Python example. https://waqtazan.com
Prints today's prayer times for a city and counts down to the next adhan.
No API key. Standard library only.
python3 example-python.py saudi-arabia riyadh
python3 example-python.py egypt cairo
python3 example-python.py pakistan karachi
"""
import json
import sys
import urllib.parse
import urllib.request
from datetime import datetime, timezone
API = "https://waqtazan.com/api/v1"
# Identify your client. Good manners for any public API — and some CDNs reject
# the default `Python-urllib/x.y` signature outright.
UA = "waqtazan-example/1.0 (+https://waqtazan.com)"
# sunrise is in the payload because Fajr ends at sunrise — but there is no adhan for it
ADHANS = ("fajr", "dhuhr", "asr", "maghrib", "isha")
LABELS = {
"fajr": "Fajr",
"sunrise": "Sunrise",
"dhuhr": "Dhuhr",
"asr": "Asr",
"maghrib": "Maghrib",
"isha": "Isha",
}
def get(path, **params):
url = f"{API}{path}"
if params:
url += "?" + urllib.parse.urlencode(params)
req = urllib.request.Request(url, headers={"User-Agent": UA})
with urllib.request.urlopen(req, timeout=15) as r:
return json.load(r)
def timings(country, city, date=None):
return get(f"/timings/{country}/{city}", **({"date": date} if date else {}))
def nearest(lat, lng):
"""Nearest city to a coordinate — pair with a GPS/IP lookup."""
return get("/nearest", lat=lat, lng=lng)
def next_adhan(day):
"""(name, seconds_remaining) for the next adhan, or None if Isha has passed."""
now = datetime.now(timezone.utc)
for name in ADHANS:
at = datetime.fromisoformat(day["timesISO"][name].replace("Z", "+00:00"))
if at > now:
return name, int((at - now).total_seconds())
return None
def main():
country = sys.argv[1] if len(sys.argv) > 1 else "saudi-arabia"
city = sys.argv[2] if len(sys.argv) > 2 else "riyadh"
day = timings(country, city)
print(f"\n {day['city']['name_ar']} · {day['city']['name_en']}")
print(f" {day['date']} {day['hijri']}")
print(f" method: {day['method']}" + (" · Ramadan" if day["isRamadan"] else ""))
print()
for name, value in day["times"].items():
mark = " " if name in ADHANS else "·" # sunrise marked, it is not a prayer
print(f" {mark} {LABELS[name]:<8} {value}")
nxt = next_adhan(day)
if nxt:
name, secs = nxt
h, m = divmod(secs // 60, 60)
print(f"\n Next: {LABELS[name]} in {h}h {m:02d}m")
else:
print("\n Isha has passed — tomorrow's Fajr is next.")
print()
if __name__ == "__main__":
main()
@dnsrobot

Copy link
Copy Markdown

nice, it's really helpful. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment