Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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. Version 2.0 is in beta: install it with pip install --pre mawaqit.

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.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

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.0b3

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.0b3
File Size Uploaded Provenance Actions
mawaqit-2.0.0b3.tar.gz 45.9 kB With provenance Details for mawaqit-2.0.0b3.tar.gz

Built distribution (wheel)

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

Total release size: 71.9 kB

Release files / mawaqit-2.0.0b3.tar.gz

Download URL mawaqit-2.0.0b3.tar.gz
Size 45.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3b378296358732f198bd2f03867f1181a458fbe23ef54614b361475a6ea2f0de
BLAKE2b-256 checksum
How to use checksums
9fa21e17b1c91af9ac428ad7a4b620d50399b569551d13236f7d43debfc414f3
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 4, 2026.

Transparency log

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

Download URL mawaqit-2.0.0b3-py3-none-any.whl
Size 26.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b13d2d43cf2f987c5e47295c23815b62b93abb5a451e8d761be5cdedaa732e0d
BLAKE2b-256 checksum
How to use checksums
cbcadb8f4482bc61df919dd08860e296a2084d9bef89d9fd70f8f7ef22689077
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 4, 2026.

Transparency log

Security for mawaqit 2.0.0b3

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.0b3.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 4, 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