Developer documentation
Building an Islamic app, dashboard, home-screen widget, or learning tool? Fetch authentic hadith narrations as structured JSON — Arabic text, English translation, book metadata, and chapter information — without hosting your own database.
The API is read-only, returns application/json, and is designed for simple integration in any language that can make HTTP requests.
Free for personal and educational projects. Commercial or high-volume use may require a separate license — see our licensing page for terms, and contact us if you need a commercial agreement or higher limits.
The fastest way to display a random hadith is a single request to GET /api:
fetch("https://randomhadith.com/api")
.then((res) => res.json())
.then((hadith) => {
console.log(hadith.text_en);
console.log(hadith.book, hadith.chapter_name_en);
});All responses are JSON. No API key is required. Requests must use HTTPS.
| Endpoint | Returns | Typical use |
|---|---|---|
| GET /api | Full random hadith object | Daily hadith widgets, one-call integrations |
| GET /api/random | { "id": number } | Pick an ID first, resolve content later |
| GET /api/hadith?id= | Full hadith by ID | Deep links, bookmarks, saved favorites |
https://randomhadith.comCombine the base URL with the endpoint path. Example: https://randomhadith.com/api/hadith?id=42
Responses draw from verified entries across major Sunni hadith compilations, including Sahih al-Bukhari, Sahih Muslim, Sunan Abi Dawud, Jami` at-Tirmidhi, Sunan an-Nasa'i, Sunan Ibn Majah. Each record includes the source book, chapter number, hadith number, and chapter titles in Arabic and English.
Browse the same content on the website via our hadith collections pages.
/api200 OKReturns a complete random hadith record.
Best for: Apps that need one request for a ready-to-display narration.
curl "https://randomhadith.com/api"{
"id": 12345,
"book": "Sahih al-Bukhari",
"chapter_no": 1,
"hadith_no": "1",
"chapter_name_en": "How the Divine Revelation started",
"chapter_name_ar": "باب كيف كان بدء الوحي",
"text_ar": "...",
"text_en": "...",
"text_ur": "..."
}/api/random200 OKReturns a random hadith ID without the full text.
Best for: Flows where you store or shuffle IDs before fetching full records.
curl "https://randomhadith.com/api/random"{
"id": 12345
}Follow with GET /api/hadith?id=12345 to load the full narration.
/api/hadith?id={id}200 OKReturns a specific hadith by numeric ID.
Best for: Permalinks, user favorites, or revisiting a previously shown hadith.
id (required) — integer from 1 to 34,477curl "https://randomhadith.com/api/hadith?id=12345"{
"id": 12345,
"book": "Sahih al-Bukhari",
"chapter_no": 1,
"hadith_no": "1",
"chapter_name_en": "How the Divine Revelation started",
"chapter_name_ar": "باب كيف كان بدء الوحي",
"text_ar": "...",
"text_en": "...",
"text_ur": "..."
}Full hadith endpoints (/api and /api/hadith) return the same object shape:
| Field | Type | Description |
|---|---|---|
| id | number | Unique identifier used across the site and API |
| book | string | Source collection name |
| chapter_no | number | Chapter number within the book |
| hadith_no | string | Hadith number as referenced in the collection |
| chapter_name_en | string | Chapter title in English |
| chapter_name_ar | string | Chapter title in Arabic |
| text_ar | string | Hadith text in Arabic |
| text_en | string | Hadith text in English |
| text_ur | string | Urdu text when available; may be an empty string |
const res = await fetch("https://randomhadith.com/api/hadith?id=12345");
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const hadith = await res.json();import requests
response = requests.get("https://randomhadith.com/api", timeout=10)
response.raise_for_status()
hadith = response.json()
print(hadith["text_en"])For production apps, call the API from your backend when possible so you can cache responses, respect rate limits, and handle errors consistently.
Public API routes share one rate limit per client IP to keep the service available for all users. Plan your integration to avoid unnecessary repeat calls.
429 Too Many Requests| Header | Description |
|---|---|
| X-RateLimit-Limit | Maximum requests allowed in the current window |
| X-RateLimit-Remaining | Requests remaining in the current window |
| X-RateLimit-Reset | Unix timestamp (seconds) when the window resets |
{
"error": "Rate limit exceeded. Please try again later."
}| Status | When | Example body |
|---|---|---|
| 400 | Missing or invalid id on /api/hadith | { "error": "Missing required parameter: id" } |
| 404 | Hadith ID not found | { "error": "Hadith not found", "id": 99999 } |
| 429 | Rate limit exceeded | { "error": "Rate limit exceeded. Please try again later." } |
| 500 | Unexpected server error | { "error": "Failed to fetch hadith", "details": "..." } |
GET /api when you only need one random hadith per user action.id if users should return to the same narration later.https://randomhadith.com/?id={id} so users can read the full page on Random Hadith.API behavior and rate limits may change as the service evolves. This page documents the current public endpoints on Random Hadith. Last updated: June 2025.
Common questions about integrating the Random Hadith API, rate limits, licensing, and production use.