Skip to main content

MAWAQIT Python library

CI PyPI Python License

The official Python library for the MAWAQIT API: search mosques, and read their prayer times, iqama times, Hijri date and screen settings.

  • Async and sync clients, with the same methods.
  • Fully typed: every argument, response and field, documented in your editor.
  • Robust: retries with backoff, timeouts, and one exception per kind of error.
  • Generated from the OpenAPI description of the API, so the methods and models follow it exactly.

Installation

pip install mawaqit

Python 3.10 or newer.

Usage

import asyncio

from mawaqit import AsyncMawaqitClient


async def main() -> None:
    async with AsyncMawaqitClient(token="...") as client:
        mosques = await client.mosques.search(lat=48.8414, lon=2.3557)
        prayer_times = await client.mosques.prayer_times(mosques[0].uuid)
        # Fajr, Shuruq, Dhuhr, Asr, Maghrib and Isha of 1 January.
        print(prayer_times.calendar[0]["1"])


asyncio.run(main())

The sync client has the same methods, without await:

from mawaqit import MawaqitClient

with MawaqitClient(token="...") as client:
    mosques = client.mosques.search(word="grande mosquée de paris")
Method Returns
client.mosques.search(word=...) or (lat=..., lon=...) A list of Mosque
client.mosques.get(mosque_id) The MosqueSummary of a mosque or a home, with its UUID
client.mosques.prayer_times(uuid) The PrayerTimes of the year, with iqama
client.mosques.hijri_settings(uuid) The HijriSettings of the mosque
client.mosques.config(uuid) The MosqueConfig: the settings of the mosque screens
client.mosques.flash_message(uuid) The FlashMessage of the mosque screens, or None

Responses are Pydantic models, from mawaqit.types, with snake_case attributes: mosque.women_space, prayer_times.iqama_calendar. model_dump(by_alias=True) gives back the JSON of the API, and fields the API adds later are kept in model_extra.

Authentication

Every method but search() needs an API token, passed as token= or set in the MAWAQIT_TOKEN environment variable.

Hijri date

mawaqit.hijri computes the Hijri date of a mosque from its settings, like the mosque screens and the app do:

from mawaqit import hijri
from mawaqit.hijri import HijriMonth

settings = await client.mosques.hijri_settings(uuid)
today = hijri.today(settings, "Europe/Paris")  # The time zone of the mosque.
print(today)  # 9 Ramadan 1448
if today.month is HijriMonth.RAMADAN:
    ...

The date changes at midnight in the time zone of the mosque. Only today's date is reliable: mosques change their settings after the moon sighting. hijri.from_gregorian(day, settings) gives the date of another day.

Errors

Every error inherits from MawaqitError:

Error When
AuthenticationError The token is wrong (HTTP 401)
PermissionDeniedError The account used all its API calls, or the request was blocked (HTTP 403)
NotFoundError No mosque has this UUID (HTTP 404)
RateLimitError, BadRequestError, InternalServerError HTTP 429, 400, 500 and above
APIStatusError Any other error status, and base class of the ones above
APIConnectionError, APITimeoutError MAWAQIT could not be reached, or did not answer in time
APIResponseValidationError The response does not match the expected model

APIError, their base class, has the failed request and the response body. APIStatusError adds the response and its status_code.

from mawaqit import AuthenticationError, MawaqitError

try:
    prayer_times = await client.mosques.prayer_times(uuid)
except AuthenticationError:
    ...  # Ask for a new token.
except MawaqitError as err:
    print(err)  # Invalid token. (HTTP 401)

Retries and timeouts

Network errors, timeouts and HTTP 408, 429, 500, 502, 503 and 504 are retried twice, after about 0.5 then 1 second, or after the delay of Retry-After when it is one minute or less. Requests time out after 30 seconds.

client = AsyncMawaqitClient(token="...", max_retries=5, timeout=10)
fast = client.with_options(max_retries=0)

Logging

Responses are logged at the DEBUG level of the mawaqit logger, and retries at the INFO level. The token is never logged.

Home Assistant

  • Pass the HTTPX client of Home Assistant to share its connection pool. It stays open when the MAWAQIT client is closed:

    client = AsyncMawaqitClient(token=token, http_client=get_async_client(hass))
    
  • Pass a tzinfo rather than a name to hijri.today(), to avoid loading a time zone in the event loop: hijri.today(settings, dt_util.get_time_zone(name)).

Versioning

This library follows Semantic Versioning. See the changelog, with the migration guide from 1.x.

Contributing

See CONTRIBUTING.md.

License

Apache 2.0. The license covers the code of this library, not access to the MAWAQIT API, which requires an authorization from MAWAQIT. Questions: support@mawaqit.net.

Metadata

Release files for mawaqit 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mawaqit 2.0.0
File Size Uploaded Provenance Actions
mawaqit-2.0.0.tar.gz 47.3 kB With provenance Details for mawaqit-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mawaqit 2.0.0
File Interpreter ABI Platform Actions
mawaqit-2.0.0-py3-none-any.whl Python 3 none any Details for mawaqit-2.0.0-py3-none-any.whl

Total release size: 73.9 kB

Release files / mawaqit-2.0.0.tar.gz

Download URL mawaqit-2.0.0.tar.gz
Size 47.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0f8456868e6fb0408f45c8dfb29bf4991a4a13976700db01980ca466499af3d2
BLAKE2b-256 checksum
How to use checksums
2b8e77e2535dda91c30e2ed80944b2b0016d0c0a321386f5fd8f0dfc41c4b834
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release files / mawaqit-2.0.0-py3-none-any.whl

Download URL mawaqit-2.0.0-py3-none-any.whl
Size 26.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae043dcfa254f0b0f3a91e199dfdc89cf75e5964857227358f48f598c57cd8de
BLAKE2b-256 checksum
How to use checksums
790a69cf78a3a4b97d31e7865018e1ee349fc006ef8ef69ae583ecf453034d25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Security for mawaqit 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mawaqit-2.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page