Skip to content

Suleeyman/hadith-rest-api

Buy Me a Coffee Swagger ReDoc License: MIT

TL;DR Check out the swagger documentation and test it. It's completely free.

⚠️ The API is currently under development therefore endpoints may vary ⚠️

🌙 Hadith REST API

Table of Contents

Summary

Free and Open Source Multilingual (arabic (+diacritics), english, bengali, indonesian, french, turkish, tamil, russian) REST API for most popular hadith editions including :

  • Forty Hadith of Shah Waliullah Dehlawi
  • Muwatta Malik
  • Sahih al Bukhari
  • Sahih Muslim
  • Sunan Abu Dawud
  • Sunan an Nasai
  • Jami At Tirmidhi
  • Forty Hadith of an-Nawawi
  • Sunan Ibn Majah
  • Forty Hadith Qudsi

Not all editions support all of those languages but english and arabic are present for all.

The API is available here : hadislam.org/

Quick summary

Open-source REST API developed with FastAPI for structured access to:

  • The most popular editions
  • Related books (i.e a big chapter of an edition)
  • Language-aware hadith
  • Grade for hadith

Why “Hadislam”?

The name Hadislam combines Hadith and Islam, reflecting the project’s purpose: to provide easy, open-source access to authentic Hadith resources. It’s designed for developers and enthusiasts who want a reliable API to explore most popular Islamic Hadith sources.

Features

  • FastAPI-based REST API
  • OpenAPI docs (/docs) and ReDoc (/redoc)
  • Pagination support for list endpoints
  • Optional language filtering

API

Endpoints

Root

  • GET / — API metadata and docs links

Edition

  • GET /editions/ — List all editions
  • GET /editions/{slug} — Get one edition by its hyphen separated latinized english name (i.e slug)

Book

  • GET /books/ — List books
  • GET /books/{book_id} — Get one book by his unique id
  • GET /editions/{slug}/books — List edition's books
  • GET /editions/{slug}/books/{book_index} — Get an edition's book at position book_index

Hadith

  • /hadiths — List hadiths
  • /hadiths/{hadith_id} — Get one book by his unique id
  • /editions/{slug}/hadiths — List edition's hadiths
  • /editions/{slug}/hadiths/{hadith_index}.{hadith_index_minor} — Get one minor (that is a sub hadith of a hadith) hadith by his numerical position inside the edition
  • /editions/{slug}/hadiths/{hadith_index} — Get one hadith (including his sub-hadith) by his numerical position inside the edition
  • /editions/{slug}/books/{book_index}/hadiths — List hadiths of an edition's book
  • /editions/{slug}/books/{book_index}/hadiths/{book_hadith_index} — Get one hadith (including his sub-hadith) by his relative numerical position inside the book

Search

  • /hadiths/search?q=... — Performs a full-text search on hadiths based on query q. English by default.

Quick Start

Requirements

  • Python >=3.12
  • uv package manager
  • pre-commit

Install

uv sync

Run (development)

uv run fastapi run src/main.py --reload

Run tests

uv run pytest tests -v --durations=0 --cov --cov-report=term-missing

Run checks

Type

uv run ty check .

Format

uv run ruff check .

Run format

uv run ruff format .

TODO

Contributor & Documentation

  • Define improvement guidelines for contributors
  • Improve API docs with request/response examples
  • Create issue templates for consistent reporting
  • Create a AGENTS.md file

API & Backend

  • Create a better rate limit policy
  • Integrate Redis for faster data retrieval
  • Add unit tests for core functionality

Development & Deployment

  • Add Docker for quick local development
  • Insert bulk data into local environment for quick start

Team

  • Add Bruno (team or collaborator)

📜 License

This project is licensed under the MIT License. See LICENSE.

💬 Feedback

Have suggestions, feedback, or need support? Open an issue or start a discussion — we’d love to hear from you.

🤝 Contributing

We welcome all kinds of contributions! Here's how you can help :

✅ Improve the Dataset

to be written

♥️ Financial support

If you want to support me financially you can buy me a coffee it will certainly motivate me on continously improving the REST API. May Allah rewards you !

You can read my ko-fi post and add a comment.

📬 A quick thank-you

If this project helped you, you can send me a message.

You don’t have to donate — even a simple message of support or a quick “thank you” means a lot and keeps me motivated to continue improving this project.

Your encouragement truly makes a difference 🙌

About

Multilingual REST API for most popular hadith editions : Sahih Al-Bukhari, Sahih Muslim, Jami At-Tirmidhi, Sunan Abu Dawud, Muwatta Malik, and much more.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

 
 
 

Contributors

Languages