Skip to main content

Unified Python wrapper for multiple Quran data sources

Project description

Quran Unified

A unified Python wrapper for multiple Quran data sources. Access Quran text, translations, audio, and tafsir through a single, simple API.

Features

  • Unified API: Single interface to access data from multiple sources
  • Multiple Data Sources: AlQuran Cloud, Quran.com, QuranEnc, Tafseer API, EveryAyah
  • Text Variants: Uthmani, Simple, and Tajweed scripts
  • Translations: 100+ translations in 40+ languages
  • Audio: Recitations from 44+ reciters
  • Tafsir: Arabic tafsir/commentary
  • Caching: Built-in memory and SQLite caching
  • CLI: Command-line interface for quick access

Installation

pip install quran-unified

For development:

pip install quran-unified[dev]

Quick Start

from quran_unified import QuranAPI

# Create API instance
quran = QuranAPI()

# Get a verse
verse = quran.get_verse(2, 255)  # Ayat al-Kursi
print(verse.arabic_uthmani)
print(verse.translation)
print(verse.audio_url)

# Get surah info
surah = quran.get_surah_info(1)
print(f"{surah.name_english}: {surah.verses_count} verses")

# Search
results = quran.search("mercy", language="en")
for v in results[:5]:
    print(f"[{v.reference}] {v.translation}")

# Get audio URL
audio = quran.get_audio_url(1, 1, reciter="alafasy")
print(audio)

# Clean up
quran.close()

Using Context Manager

from quran_unified import QuranAPI

with QuranAPI() as quran:
    verse = quran.get_verse(1, 1)
    print(verse.arabic_uthmani)

CLI Usage

# Get a verse
quran verse 2:255
quran verse 2:255 --translation en.sahih --json

# Get surah info
quran surah 1
quran surah 1 --info-only

# Search
quran search "الرحمن"
quran search "mercy" --language en --limit 10

# Get tafsir
quran tafsir 2:255 --tafsir-id 1

# Get audio URL
quran audio 1:1 --reciter alafasy

# List reciters
quran reciters

# List translations
quran translations --language ar

Configuration

quran = QuranAPI(
    default_translation="en.sahih",  # Default translation
    default_reciter="alafasy",       # Default reciter
    default_tafsir=1,                # Default tafsir ID
    cache_backend="memory",          # "memory", "sqlite", or "none"
    cache_ttl=3600,                  # Cache TTL in seconds
    timeout=30,                      # Request timeout
    retries=3,                       # Retry attempts
)

API Reference

Verse Methods

Method Description
get_verse(surah, ayah, ...) Get a single verse
get_verses(surah, from_ayah, to_ayah, ...) Get a range of verses
get_random_verse(translation) Get a random verse

Surah Methods

Method Description
get_surah(surah, ...) Get surah with verses
get_surah_info(surah) Get surah metadata only
get_all_surahs() Get all 114 surahs

Division Methods

Method Description
get_juz(juz, translation) Get verses in a juz (1-30)
get_hizb(hizb, translation) Get verses in a hizb (1-60)
get_page(page, translation) Get verses on a page (1-604)

Tafsir Methods

Method Description
get_tafsir(surah, ayah, tafsir_id) Get tafsir for a verse
get_available_tafsirs() List available tafsirs

Audio Methods

Method Description
get_audio_url(surah, ayah, reciter) Get audio URL
get_surah_audio_urls(surah, reciter) Get all audio URLs for surah
get_available_reciters() List available reciters

Search & Utility

Method Description
search(query, language, surah, limit) Search the Quran
get_available_translations(language) List translations
get_verse_count(surah) Get verse count for surah
clear_cache() Clear cached data

Data Sources

Source URL Data Provided
AlQuran Cloud api.alquran.cloud Text, translations, search
Quran.com api.quran.com Rich metadata, search
QuranEnc quranenc.com Translations with footnotes
Tafseer API api.quran-tafseer.com Arabic tafsirs
EveryAyah everyayah.com Audio recitations

License

MIT License - see LICENSE for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project details


Download files

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

Source Distribution

quran_unified-0.1.0.tar.gz (27.6 kB view details)

Uploaded Source

Built Distribution

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

quran_unified-0.1.0-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

Details for the file quran_unified-0.1.0.tar.gz.

File metadata

  • Download URL: quran_unified-0.1.0.tar.gz
  • Upload date:
  • Size: 27.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for quran_unified-0.1.0.tar.gz
Algorithm Hash digest
SHA256 da3b0507a4c7e6df03ac3f82f175ca549434abf38cf8f67a91ff14a83de21731
MD5 70ecb573b27abb29a2668b3572f91518
BLAKE2b-256 2f60fb644149f31c3dec5638e805d83242fa4b39b4c720ac700609d138cab655

See more details on using hashes here.

File details

Details for the file quran_unified-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: quran_unified-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 28.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for quran_unified-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b117834f7c0dabf0d1321131a48f19edee8b6672727b538b95daaa2136307cc7
MD5 285914cdab19acdd2680a6739b5b2a38
BLAKE2b-256 b33b1a30bfc7e376eda89f2a49132a0fde2fd8bd0872d83c2e0fe1a8683fb042

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page