API Documentation

Libya Prayer Times API

Free public REST API serving prayer times for 28 Libyan cities. No authentication required.

REST / JSON CORS Enabled Public Read 28 Cities

Overview

Access daily prayer times (Fajr, Sunrise, Dhuhr, Asr, Maghrib, Isha) for 28 Libyan cities. Some cities also include Imsak and Keroob (pre-sunset) times.

No API key needed. Simply append .json to any path for a JSON response. Works from any domain.

Key Features

  • 366 days of prayer times per city (full year)
  • Times in HH:MM format (24-hour, Libya UTC+2)
  • Arabic and English city names in metadata
  • Optional Imsak / Keroob fields for supported cities
  • CORS enabled — works from any domain

Base URL

https://api.prayertimes.ly

All endpoints are relative to this base URL.

Endpoints

GET /metadata.json

Returns global metadata: version, last updated date, city count, and all city keys.

GET /cities/{city}/metadata.json

Returns metadata for a specific city including Arabic/English names and Imsak/Keroob availability.

ParameterTypeDescription
{city}stringCity key (lowercase). See Cities.
GET /cities/{city}/days/{DD-MM}.json

Returns prayer times for a specific city on a specific day.

ParameterTypeDescription
{city}stringCity key (lowercase)
{DD-MM}stringDay-month, zero-padded. e.g. 04-04
{ "fajer": "05:25", "shorok": "06:50", "dohor": "13:13", "aser": "16:43", "magrib": "19:32", "esha": "20:54", "emsak": "05:14", "keroob": "19:28" }
emsak and keroob fields are only present for cities where has_emsak / has_keroob is true.
GET /cities/{city}/days.json

Returns all prayer times for a city (366 days). Response is ~30-40 KB per city.

ParameterTypeDescription
{city}stringCity key (lowercase)
Large response. Use the single-day endpoint if you only need one day. Best for caching all data locally.

Available Cities

28 Libyan cities are available. Use the lowercase key in API paths:

aljaghbubAl Jaghbub
alkomsAl Khoms
almaragAl Marj
alzaweyaAzzawya
banywaleadBani Walid
bedaAl Bayda
benghaziBenghazi
benjuwadBin Jawad
breakaBrega
dernaDerna
ejdabyaAjdabiya
ekdamesGhadames
emsaedMusaid
hoonHun
jaloJalu
koufraAl Kufra
mawaMawa
mosrataMisrata
nalutNalut
ojalaAwjila
raslanofRas Lanuf
sabhaSabha
sertSirte
shahatShahhat
tobrekTobruk
tripoliTripoli
ubariUbari
zaleatenZliten

Response Format

Prayer Time Fields

FieldFormatDescriptionRequired
fajerHH:MMFajr (dawn prayer)Yes
shorokHH:MMSunriseYes
dohorHH:MMDhuhr (noon prayer)Yes
aserHH:MMAsr (afternoon prayer)Yes
magribHH:MMMaghrib (sunset prayer)Yes
eshaHH:MMIsha (night prayer)Yes
emsakHH:MMImsak (fasting start)Optional*
keroobHH:MMKeroob (pre-sunset)Optional*

*Check has_emsak / has_keroob in city metadata. Cities without: Benghazi, Mawa, Al Jaghbub, Al Khoms, Nalut.

Time Zone

All times are in Libya time (UTC+2). Libya does not observe daylight saving time.

Date Key Format

Day keys use DD-MM format (day-month), zero-padded. Examples: 01-01 (Jan 1), 31-12 (Dec 31), 29-02 (Feb 29).

Error Handling

Non-existent paths return an HTTP 404. Always verify the city key and date format before making requests.

Code Examples

Get Today's Prayer Times

# Get prayer times for Tripoli on April 4th curl "https://api.prayertimes.ly/cities/tripoli/days/04-04.json" # Get city metadata curl "https://api.prayertimes.ly/cities/tripoli/metadata.json" # List all cities curl "https://api.prayertimes.ly/metadata.json"

Embeddable Widget

<!-- Embed prayer times in your website --> <div id="prayer-widget"></div> <script> (async () => { const city = 'tripoli'; const d = new Date(); const key = String(d.getDate()).padStart(2,'0') + '-' + String(d.getMonth()+1).padStart(2,'0'); const base = 'https://api.prayertimes.ly'; const [times, meta] = await Promise.all([ fetch(`${base}/cities/${city}/days/${key}.json`).then(r => r.json()), fetch(`${base}/cities/${city}/metadata.json`).then(r => r.json()), ]); const prayers = [ ['Fajr', times.fajer], ['Dhuhr', times.dohor], ['Asr', times.aser], ['Maghrib', times.magrib], ['Isha', times.esha], ]; const el = document.getElementById('prayer-widget'); const h = document.createElement('h3'); h.textContent = meta.name_en + ' Prayer Times'; el.appendChild(h); prayers.forEach(([n,t]) => { const row = document.createElement('div'); row.textContent = n + ': ' + t; el.appendChild(row); }); })(); </script>

Try It Live

Enter a city key and date to fetch prayer times directly from the API.

GET /cities/{city}/days/{DD-MM}.json

Usage Notes

Best practice: Cache responses locally. Prayer times don't change during the day — a single fetch per city per day is sufficient. Use /days.json to fetch all days at once.

CORS

The API supports CORS. You can call it directly from browser JavaScript on any domain.

Caching

Responses include a Cache-Control: max-age=3600 header. Prayer data is static and updated yearly.