Skip to main content

quran-foundation-api

Official Python SDK for Quran Foundation APIs.

pip install quran-foundation-api
from quran_foundation import QuranClient

client = QuranClient(client_id="YOUR_CLIENT_ID", access_token="ACCESS_TOKEN")
chapters = client.list_chapters()
print(chapters)

Content and search

from quran_foundation import QuranClient

client = QuranClient(client_id="YOUR_CLIENT_ID", access_token="ACCESS_TOKEN")

chapter = client.get_chapter(1)
verses = client.get_verses_by_range("1:1", "1:7", translations="131")
translations = client.list_translations()
results = client.search("mercy", mode="advanced", params={"size": 10})

Content resource sync

Word-by-word translations can be included in content sync and fetched as resource snapshots:

changes = client.sync_resources(
    params={
        "bootstrap": True,
        "resources": "word_by_word_translations:85",
    }
)
snapshot = client.get_word_by_word_translation_snapshot(85)

The API exposes approved, shareable word-translation resources and returns their snapshot records in canonical word_id, priority, and id order. Transliteration resources are excluded.

For endpoints that do not yet have a dedicated helper, use the service request helpers:

client.content_request("/verses/by_page/1", params={"translations": "131"})
client.search_request("/api/v1/search", params={"query": "mercy", "mode": "quick"})
client.user_request("/bookmarks", params={"page": 1})

User APIs

Use signed-in User API helpers with a user access token. Keep the token server-side.

profile = client.get_profile()
bookmarks = client.list_bookmarks()
client.create_bookmark({"verse_key": "2:255", "mushaf_id": 1})
client.update_preference({"key": "theme", "value": "dark"})

OAuth2 helpers

Use OAuth helpers on the server side. Never expose client_secret, access tokens, or refresh tokens to browser code.

from quran_foundation.oauth import build_authorization_url, create_pkce_pair, exchange_code

verifier, challenge = create_pkce_pair()
authorize_url = build_authorization_url(
    client_id="YOUR_CLIENT_ID",
    redirect_uri="https://your-app.com/callback",
    scope="openid offline_access user bookmark",
    state="random-state",
    code_challenge=challenge,
)

tokens = exchange_code(
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET",
    code="CODE_FROM_CALLBACK",
    code_verifier=verifier,
    redirect_uri="https://your-app.com/callback",
)

Development

python -m pip install -e ".[dev]"
ruff check .
pytest
python -m build
twine check dist/*

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quran_foundation_api-0.1.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quran_foundation_api-0.1.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file quran_foundation_api-0.1.1.tar.gz.

File metadata

  • Download URL: quran_foundation_api-0.1.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for quran_foundation_api-0.1.1.tar.gz
Algorithm Hash digest
SHA256 af0ab9f500d3ab72c6a2afaf99913fa156a6fba7cf5ece4d5af150c15aaf296f
MD5 21cc2f0c9a3385c999e7350ece00ef81
BLAKE2b-256 f995802bea39b5c55f40e103be4da465358a5dec7e11f8e39fc9e0930ae6c55e

See more details on using hashes here.

Provenance

The following attestation bundles were made for quran_foundation_api-0.1.1.tar.gz:

Publisher: publish.yml on quran/api-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quran_foundation_api-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for quran_foundation_api-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c6496624d5e1f18463dbde85d94d41c684acfeced572718cb9d0866cbeca4722
MD5 dd7030f2b239522e928e42892ca865d4
BLAKE2b-256 52d73ec3d4a3b90fa7f04bfa3b97945a7b55be904a183efa7697d84543b74f86

See more details on using hashes here.

Provenance

The following attestation bundles were made for quran_foundation_api-0.1.1-py3-none-any.whl:

Publisher: publish.yml on quran/api-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.3

2 files

0.1.2

2 files

This release

0.1.1 This release

2 files

0.1.0

2 files

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