Developer API

Quran AI Search API

A free AI-powered search API for the Noble Quran. Describe a theme, story, or question in plain language and get relevant surah and verse references with short AI explanations as JSON.

POST
/api/ai-search
JSON response
Free to use

Overview

The AI search API matches natural-language queries to surahs and verses in the Quran using semantic AI. It is designed for integrators who want theme-based discovery without building their own search index or LLM pipeline.

  • Returns a single JSON response you can parse with any HTTP client.
  • Writes each result's relevance blurb in the language you pass in, or auto-detects the query language (detectedLanguage) when you omit it.
  • Returns structured surah and verse numbers your app can link to.

Please link back

This API is free to use. If you build something with it, we would be grateful if you could link back to OpenQuran.app — for example wherever search results appear, or in your credits or about page.

An example link you might use:

HTML
<a href="https://openquran.app" rel="noopener">Quran search by OpenQuran.app</a>

We share this work freely for the sake of the Quran. A small link back helps others discover the reader and means a great deal to us.

Endpoint

Send a JSON body with the user's search phrase. The API responds with a single JSON object containing the matched references.

URL
POST https://openquran.app/api/ai-search

Headers

HeaderValueNotes
Content-Typeapplication/jsonRequired

Request

The request body is a single JSON object:

JSON body
{
  "query": "patience in hardship",
  "language": "en"
}

Constraints

  • Query must be 2–300 characters after trimming.
  • language is optional: an ISO 639-1 code (e.g. en, ar, fr) for the relevance explanations. When omitted or invalid, the language is auto-detected from the query.
  • At most 12 results per query.
  • Leading and trailing whitespace is stripped.

Response

Successful requests return HTTP 200 with a JSON object.

Content-Type: application/json

Example response
{
  "ok": true,
  "results": [
    {
      "type": "surah",
      "surah": 2,
      "relevance": "Covers patience through trials."
    },
    {
      "type": "verse",
      "surah": 2,
      "ayah": 255,
      "relevance": "Ayat al-Kursi speaks of steadfastness in faith."
    }
  ],
  "detectedLanguage": "en"
}

Each item in results includes a relevance field. That text is written in the language you requested, or in the detected query language (detectedLanguage) when no language was provided — for example, an Arabic query yields Arabic relevance blurbs.

Top-level fields

FieldTypeNotes
oktrueAlways true on success.
resultsarrayOrdered list of surah or verse references (see Result types).
detectedLanguagestring | nullISO 639-1 code for the language detected from the query. Relevance strings use the language from your request when provided, otherwise this detected language.

Result types

Each result is a tagged object — either a whole surah or a single verse:

SemanticSearchResult
// Whole surah reference
{ "type": "surah", "surah": 2, "relevance": "One sentence explaining the match." }

// Single verse reference
{ "type": "verse", "surah": 2, "ayah": 255, "relevance": "One sentence explaining the match." }
  • surahSurah number, 1–114.
  • ayah1-based verse number within the surah (verse results only).
  • relevanceOne-sentence explanation of why the reference matches, written in the requested language or the detected query language. Null for quick-reference lookups.

Quick reference

Bare surah numbers and verse references skip the AI model and resolve instantly:

  • 2navigate to Surah 2
  • 2:255navigate to verse 255 of Surah 2

Quick-reference queries return immediately with relevance set to null on each result.

Rate limits

To keep the service free and available, each client IP is limited to 10 requests per 60 seconds.

  • Limits are tracked per IP address using standard proxy headers (`X-Forwarded-For`, `X-Real-IP`).
  • When limited, the API returns HTTP 429 with a `Retry-After` header (seconds until you can retry).
  • Automated scraping, bulk querying, or attempts to circumvent limits may result in blocking.
429 Too Many Requests
{
  "ok": false,
  "error": "Too many requests. Please slow down."
}

Error responses

Failed requests return a JSON body with ok set to false and a short error message.

StatusMeaning
400Invalid JSON, empty query, or query shorter than the minimum length.
429Rate limit exceeded. Check the 'Retry-After' header (seconds).
502The search service failed unexpectedly.
503AI search is not configured on this deployment.

All error responses use the shape: 'ok': false, 'error': "message".

Code examples

cURL

curl
curl -X POST 'https://openquran.app/api/ai-search' \
  -H 'Content-Type: application/json' \
  -d '{"query":"patience in hardship"}'

JavaScript

JavaScript (fetch)
const response = await fetch('https://openquran.app/api/ai-search', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ query: 'patience in hardship' }),
});

if (!response.ok) {
  const error = await response.json();
  throw new Error(error.error ?? response.statusText);
}

const data = await response.json();
console.log(data.results);

Disclaimer

Results are generated by an AI model and may be incomplete or imperfect. They are pointers to help people explore the Quran — not religious rulings or authoritative interpretation. Always read verses in their full context.

By using this API you agree to our Terms of Service and Privacy Policy.