Quran, Hadith, translations and approved audio
The external API is intentionally stricter than the public website: only content that is both publication-approved and source/reuse-approved is eligible to leave KitabGrid.
1. Access flow
- Submit the domain/subdomain, contact details, intended use, requested data scopes and translation languages.
- Verify the compulsory email address.
- KitabGrid manually reviews the website, requested scopes and licensing implications.
- After approval, a short-lived one-time claim link generates the credential. The raw key is not stored or emailed.
2. Authentication and key types
kg_live_… — server secret. Keep it backend-only. A request carrying this key is rejected when an Origin header indicates browser use.
kg_pub_… — browser credential. It is usable only from the exact approved HTTPS origin and is not treated as a private secret.
Do not use query-string API keys. Keys belong in an HTTP header so they are less likely to leak through URLs, referrers or logs.
3. API endpoints
| Method | Endpoint | Scope | Purpose |
|---|---|---|---|
| GET | /client | authenticated | Current client, domain, scopes and quota. |
| GET | /languages | authenticated | Languages granted to the client and available publicly. |
| GET | /quran/surahs | quran.read | 114-Surah catalogue where approved data exists. |
| GET | /quran/surahs/{surah} | quran.read | Surah metadata. |
| GET | /quran/surahs/{surah}/ayahs | quran.read | Paginated ayahs; translations/audio can be included. |
| GET | /quran/ayahs/{surah}/{ayah} | quran.read | Single ayah with optional translations/audio. |
| GET | /quran/reciters | quran.audio.read | Approved reciters with reusable audio sources. |
| GET | /hadith/search?q=... | hadith.read | Search approved published Hadith records. |
| GET | /hadith/collections | hadith.read | Published/partial approved collections. |
| GET | /hadith/collections/{slug} | hadith.read | Collection metadata. |
| GET | /hadith/collections/{slug}/hadiths | hadith.read | Paginated approved Hadith records. |
| GET | /hadith/collections/{slug}/hadiths/{number} | hadith.read | Single Hadith with optional approved translations/audio. |
4. Common parameters
lang=en,pl- Comma-separated granted translation languages, maximum 5.
include=translations,audio- Adds only the requested optional blocks and only when the matching scope is granted.
reciter={id}- Selects a specific approved Quran reciter. If unavailable, another reciter is not silently substituted.
page/per_page- Pagination. per_page is capped at 50.
5. Content, source and licence rules
- Quran/Hadith source text is returned only through approved source records.
- Translations must be approved; Hadith translations also respect a published translation-version gate where that workflow exists.
- Audio is returned only when the audio source itself is approved for reuse. Hadith audio support exists, but returns no audio until approved narration records are actually stored.
- Source blocks can include title, author/translator, publisher, edition, source URL, licence name/URL and reuse scope. Integrators must preserve required attribution and source-specific licence notices.
6. Rate limits, CORS and errors
The default approval profile is 60 requests/minute and 10,000/day, but administrators can assign a different limit per client. A 429 response means the current limit was exceeded.
Browser credentials receive an exact Access-Control-Allow-Origin only for the approved domain/subdomain. Wildcard CORS is not used for authenticated browser access.
| HTTP | Meaning |
|---|---|
| 400 | Invalid parameter or malformed request. |
| 401 | Missing/invalid/revoked credential. |
| 403 | Scope, language, origin or client state does not allow the request. |
| 404 | No eligible approved public record exists. |
| 429 | Rate or daily quota exceeded. |
| 503 | Required API storage/data dependency is unavailable. |
