Official Python SDK for Quran Foundation APIs.
Project description
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})
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/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quran_foundation_api-0.1.0.tar.gz.
File metadata
- Download URL: quran_foundation_api-0.1.0.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a0d260287de62f0d2fb893e26861985a5947aa513782fcc43938de40baf72c2
|
|
| MD5 |
f7a05c14b0e25ea6d155348afd062bca
|
|
| BLAKE2b-256 |
efcbb2b5214d716768088f1dbfc9f19f5697441d66683e4973f5e015d597f2df
|
Provenance
The following attestation bundles were made for quran_foundation_api-0.1.0.tar.gz:
Publisher:
publish.yml on quran/api-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quran_foundation_api-0.1.0.tar.gz -
Subject digest:
3a0d260287de62f0d2fb893e26861985a5947aa513782fcc43938de40baf72c2 - Sigstore transparency entry: 1838010511
- Sigstore integration time:
-
Permalink:
quran/api-python@5448e4921f4a232d18ad02f92222dd8142dacea5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/quran
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5448e4921f4a232d18ad02f92222dd8142dacea5 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file quran_foundation_api-0.1.0-py3-none-any.whl.
File metadata
- Download URL: quran_foundation_api-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce873eba34c1134fdeb2c3ce6a7f6bffc5abc82afb006f121efd82779ad080a4
|
|
| MD5 |
b34da449148371783e135bc257b9bfbe
|
|
| BLAKE2b-256 |
ba2e7215f0941d6e017605695ff757f0ef4d8d22b2e5766234c8e7d5b0226488
|
Provenance
The following attestation bundles were made for quran_foundation_api-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on quran/api-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quran_foundation_api-0.1.0-py3-none-any.whl -
Subject digest:
ce873eba34c1134fdeb2c3ce6a7f6bffc5abc82afb006f121efd82779ad080a4 - Sigstore transparency entry: 1838010601
- Sigstore integration time:
-
Permalink:
quran/api-python@5448e4921f4a232d18ad02f92222dd8142dacea5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/quran
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5448e4921f4a232d18ad02f92222dd8142dacea5 -
Trigger Event:
workflow_dispatch
-
Statement type: