Quran Foundation API Documentation

website·Indexed 32 days ago

https://api-docs.quran.foundation/

Technical documentation and OpenAPI specifications for Quran Foundation services, including Content APIs v4, Search API v1, User-related APIs v1, OAuth2/OIDC integration, and Analytics Events API. Includes integration guides and SDK prompts for JavaScript, Python, Next.js, and SvelteKit.

Tokens
144.2K
Snippets
729
Records
976
Agent score
67%

What's inside Quran Foundation

  1. Integrate Quran Foundation JS SDK based on application type

    The integration strategy for the @quranjs/api SDK depends on the application type configured in the Developer Console. Choose the architecture that prevents the exposure of secrets in the browser or mobile environment.
    npm install @quranjs/api
  2. Get information for a specific Tafsir

    v4.json

    Retrieve detailed information about a specific Tafsir, such as author and publication details, using the /resources/tafsirs/{tafsir_id}/info endpoint.

    Path Parameters:

    • tafsir_id (string, required): The unique identifier of the tafsir.

    Response: Returns a JSON object containing an info object with the id (integer) and info (string), where the latter is Markdown or HTML text describing the resource.

  3. Understand the AnswersQuestionDto schema

    v4.json
    The AnswersQuestionDto object represents a question within the Quran foundation content system. It includes details about the question text, its classification, associated Quranic verses, and its current publication status.
    {
      "id": "string",
      "body": "string",
      "type": "CLARIFICATION | TAFSIR | COMMUNITY",
      "ranges": ["string"], // e.g. "2:255-2:257"
      "surah": "integer",
      "theme": ["string"],
      "summary": "string",
      "references": ["string"],
      "language": "string", // ISO code
      "status": "New | Draft | Published | Answered",
      "answers": ["AnswersAnswerDto"]
    }
  4. Understand the Quran translation response schema

    v4.json

    The translation API returns a value object containing a list of translations. Each translation object includes metadata about the verse and the translation resource. Key fields include:

    • resource_id: Unique identifier for the translation resource.
    • text: The translated text of the verse.
    • verse_key: The chapter and verse identifier (e.g., "1:1").
    • language_name: The language of the translation.
    • foot_notes: An object containing footnote markers and their corresponding text (if foot_notes=true is requested).
    • meta: Contains the translation_name, author_name, and the filters applied to the request.
  5. Retrieve recitation information

    v4.json
    Retrieve detailed information about a specific recitation by sending a GET request to the /resources/recitations/{recitation_id}/info endpoint. This request requires authentication via custom headers.
    curl -X GET \
      'https://apis.quran.foundation/content/api/v4/resources/recitations/{recitation_id}/info' \
      -H 'x-auth-token: <YOUR_ACCESS_TOKEN>' \
      -H 'x-client-id: <YOUR_CLIENT_ID>'
  6. Get details for a specific chapter

    v4.json
    Retrieve detailed information about a single chapter using its ID (ranging from 1 to 114). The response includes the chapter's revelation place, order, verse count, and translated names. An optional language query parameter (defaults to "en") can be used to specify the translation language.
    // Node.js example using axios
    const axios = require('axios');
    
    const API_BASE_URL = 'https://apis.quran.foundation/content/api/v4';
    const ACCESS_TOKEN = '<YOUR_ACCESS_TOKEN>';
    const CLIENT_ID = '<YOUR_CLIENT_ID>';
    
    async function getChapter(id, options = {}) {
      const response = await axios.get(
        `${API_BASE_URL}/chapters/${id}`,
        {
          headers: {
            'x-auth-token': ACCESS_TOKEN,
            'x-client-id': CLIENT_ID
          },
          params: options
        }
      );
      return response.data;
    }
    
    // Example: Get Chapter 1 in English
    getChapter("1", {"language":"en"})
      .then(data => console.log(data))
      .catch(err => console.error(err.response?.status, err.message));
  7. Retrieve Tafsir information

    v4.json
    To retrieve information about a specific Tafsir, send a GET request to the /resources/tafsirs/{tafsir_id}/info endpoint. This request requires authentication via custom headers for both the access token and the client ID.
    curl -X GET \
      'https://apis.quran.foundation/content/api/v4/resources/tafsirs/169/info' \
      -H 'x-auth-token: <YOUR_ACCESS_TOKEN>' \
      -H 'x-client-id: <YOUR_CLIENT_ID>'
  8. Understand Uthmani verse response structure

    v4.json
    The response for Uthmani verse requests returns a list of verse objects. Each verse object contains an id, a verse_key (e.g., "1:1"), and the text_uthmani containing the Arabic script. The meta object provides information about the filters applied to the request, such as chapter_number or verse_key.
    {
      "verses": [
        {
          "id": 1,
          "verse_key": "1:1",
          "text_uthmani": "بِسْمِ ٱللَّهِ ٱلرَّحْمَـٰنِ ٱلرَّحِيمِ"
        }
      ],
      "meta": {
        "filters": {
          "chapter_number": 1
        }
      }
    }
  9. Retrieve chapter information

    v4.json
    Get information about Quran chapters using the /resources/chapter_infos endpoint. This request requires authentication via custom headers for both the access token and client ID.
    curl -X GET \
      'https://apis.quran.foundation/content/api/v4/resources/chapter_infos' \
      -H 'x-auth-token: <YOUR_ACCESS_TOKEN>' \
      -H 'x-client-id: <YOUR_CLIENT_ID>'
  10. List connected apps for the authenticated user

    v1.json
    Retrieve a list of logical apps linked via OAuth for the authenticated user. This endpoint returns metadata about the apps, including their environment (prelive or production), storage status, and grant scopes. It does not return raw OAuth client or App State namespace identifiers.
    GET /users/connected-apps

    Response (200 OK):

    {
      "success": true,
      "data": {
        "apps": [
          {
            "appId": "123e4567-e89b-12d3-a456-426614174000",
            "name": "string",
            "environment": "prelive",
            "logoUrl": "string",
            "appUrl": "string",
            "storage": {
              "status": "active",
              "categories": ["string"]
            },
            "grant": {
              "status": "active",
              "scopes": ["string"],
              "effectiveScopes": ["string"]
            },
            "connectedAt": "2026-04-02T00:00:00.000Z",
            "lastAccessedAt": "2026-04-02T00:00:00.000Z"
          }
        ]
      }
    }
  11. Understand the PostSerialized data model

    v1.json

    The PostSerialized object represents a detailed post. Key properties include metadata about the author, room, and moderation status.

    Moderation Status (moderationStatus):

    • 1: Featured (Sticky posts, shown at top of feed)
    • 2: Promoted (High quality content)
    • 3: Normal (Default, available in search/latest/popular)
    • 4: Hidden (Visible only to author/moderators or via private link)
    • 5: Private Note (Moderator-made private)
    • 6: Requested Review (Hidden, pending review)
    • 30: Deleted

    Room Post Status (roomPostStatus):

    • 0: As Room
    • 1: Publicly
    • 2: Only Members

    Review Status (reviewStatus):

    • 1: Reviewed
    • 2: Pending Review
    • 100: Legacy
    {
      "type": "object",
      "properties": {
        "id": { "type": "number" },
        "authorId": { "type": "string" },
        "body": { "type": "string" },
        "roomId": { "type": "number" },
        "moderationStatus": { "enum": [1, 2, 3, 4, 5, 6, 30], "type": "number" },
        "roomPostStatus": { "enum": [0, 1, 2], "type": "number" },
        "createdAt": { "format": "date-time", "type": "string" }
      }
    }
  12. Understand the Pagination schema for Content APIs

    v4.json
    The Pagination object is used across the Content APIs to handle paginated responses. It provides metadata about the current page, the total number of records, and the total number of pages available.
    {
      "per_page": 10,
      "current_page": 1,
      "next_page": 2, // Integer or null if this is the last page
      "total_pages": 1,
      "total_records": 7
    }