Get accurate Islamic prayer times (Fajr, Dhuhr, Asr, Maghrib, Isha) for any location worldwide using official calculation methods. Use when users ask about prayer times, Salat schedules, next prayer, or need to set up automated prayer reminders. Includes automated background reminder system that alerts users 10 minutes before, at prayer time, and 5 minutes after - even during conversations. Supports 20+ country-specific calculation methods including Morocco, Saudi Arabia, Egypt, Turkey, UAE, and more.
Get accurate Islamic prayer times for any location using the AlAdhan API with region-specific calculation methods, plus automated reminders that work in the background.
Ask about prayer times for any location, get next prayer info, or check specific dates.
Set up cron jobs that fetch daily prayer times and check periodically for reminders. Alerts you:
To set up reminders: See references/setup-reminders.md for complete guide.
By city and country:
cd scripts/
python3 get_prayer_times.py --city Mecca --country "Saudi Arabia"
python3 get_prayer_times.py --city Istanbul --country Turkey
python3 get_prayer_times.py --city Cairo --country Egypt
By coordinates:
python3 get_prayer_times.py --lat 21.4225 --lon 39.8262 # Mecca
With next prayer info:
python3 get_prayer_times.py --city Istanbul --country Turkey --next --timezone 3
📍 Mecca, Saudi Arabia
📆 10 Feb 2026
🌙 22-08-1447
🔢 Method: 4
🕌 Fajr 05:37
🌅 Sunrise 06:54
🕌 Dhuhr 12:35
🕌 Asr 15:50
🕌 Maghrib 18:16
🕌 Isha 19:46
⏳ Next: Maghrib at 18:16 (in 15 minutes)
The script automatically selects the correct calculation method based on country:
When to override: Only specify --method if you need a different calculation than the country default.
For full method list and details, see references/methods.md.
get_prayer_times.pyLocation: scripts/get_prayer_times.py
Purpose: Fetch prayer times for any location.
Arguments:
--city <name> - City name (e.g., "Rabat")--country <name> - Country name (e.g., "Morocco")--lat <float> - Latitude coordinate--lon <float> - Longitude coordinate--method <id> - Calculation method ID (1-24, optional)--date <DD-MM-YYYY> - Specific date (optional, defaults to today)--timezone <hours> - Timezone offset from UTC for "next prayer" calculation--next - Show next prayer and time remaining--json - Output as JSONReturns:
check_prayer_reminder.pyLocation: scripts/check_prayer_reminder.py
Purpose: Check if it's time to send a prayer reminder. Designed for periodic cron execution.
Arguments:
--prayer-times <path> - Path to prayer_times.json file (required)--timezone <hours> - Timezone offset from UTC (required)--json - Output as JSONReturns:
Reminder Windows:
python3 get_prayer_times.py --city "User's City" --country "User's Country" --next --timezone <offset>
from get_prayer_times import get_prayer_times
import json
# Fetch and save
times = get_prayer_times(city="Rabat", country="Morocco")
with open('prayer_times.json', 'w') as f:
json.dump(times, f)
from get_prayer_times import get_prayer_times, get_next_prayer
times = get_prayer_times(city="Rabat", country="Morocco")
next_prayer = get_next_prayer(times, timezone_offset=1) # GMT+1 for Morocco
print(f"Next: {next_prayer['name']} in {next_prayer['hours_until']}h {next_prayer['minutes_until']}m")
Complete setup guide: references/setup-reminders.md
Quick setup:
Create daily fetch job (runs at midnight):
prayer_times.jsonCreate reminder check job (runs every 5 min):
Example prompts to set up:
Set up prayer time reminders for Mecca, Saudi Arabia (GMT+3).
Fetch daily at midnight and check every 5 minutes.
Set up prayer time reminders for Istanbul, Turkey (GMT+3).
Fetch daily at midnight and check every 5 minutes.
Set up prayer time reminders for Cairo, Egypt (GMT+2).
Fetch daily at midnight and check every 5 minutes.
This enables background reminders even while chatting - you'll never miss Salat!
The AlAdhan API (api.aladhan.com) may be unreachable from some datacenter IPs (e.g., DigitalOcean → Hetzner routing issues).
Solution: Use Cloudflare WARP or similar VPN to route traffic through Cloudflare's network.
Quick fix:
# Install Cloudflare WARP
curl -fsSL https://pkg.cloudflareclient.com/pubkey.gpg | sudo gpg --yes --dearmor --output /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/cloudflare-client.list
sudo apt update && sudo apt install cloudflare-warp
warp-cli register
warp-cli connect
The API returns times in local time for the queried location. When calculating "time until next prayer", use the appropriate timezone offset.
python3 get_prayer_times.py --city Mecca --country "Saudi Arabia"
python3 get_prayer_times.py --city Istanbul --country Turkey --next --timezone 3
python3 get_prayer_times.py --lat 40.7128 --lon -74.0060 --next --timezone -5
# New York coordinates
python3 get_prayer_times.py --city Cairo --country Egypt --date 15-03-2026
Test the script locally:
cd scripts/
python3 get_prayer_times.py --city Rabat --country Morocco --next --timezone 1
Expected output should show 5 prayer times (Fajr, Dhuhr, Asr, Maghrib, Isha) plus Sunrise, and indicate the next upcoming prayer if --next is used.