Developers

Build powerful applications with the Tafheem Research Lab API. Access comprehensive Quranic data, translations, and scholarly commentaries.

Base URL

text
https://app.tafheemulquran.net/api/v1

All API endpoints are relative to the base URL above. For local development, use:

text
http://localhost:8000/api/v1

API Specification

Interactive API documentation is available at:

Authentication

Most endpoints require authentication using JWT (JSON Web Token). Register or log in to obtain a token.

Public Endpoints: Ayah, translation, and Tafseer data endpoints do not require authentication.

User Registration

http
POST /api/v1/users/register
Content-Type: application/json

{
  "email": "developer@example.com",
  "password": "SecurePassword123!",
  "username": "developer"
}

User Login

http
POST /api/v1/users/login
Content-Type: application/json

{
  "email": "developer@example.com",
  "password": "SecurePassword123!"
}

Response:
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "email": "developer@example.com",
    "username": "developer",
    "role": "user"
  }
}

Using the Token

Include the access token in the Authorization header:

bash
curl -H "Authorization: Bearer {access_token}" \
  https://app.tafheemulquran.net/api/v1/users/me

Access Quranic verses (Ayahs) with full text, translations, and metadata.

Get All Ayahs

http
GET /api/v1/ayahs/?skip=0&limit=10

Response:
[
  {
    "id": 1,
    "surah_id": 1,
    "ayah_number": 1,
    "text_arabic": "بِسْمِ اللَّهِ الرَّحْمَـٰنِ الرَّحِيم",
    "page_number": 1,
    "juz_number": 1,
    "sajda": false
  },
  ...
]

Get Ayahs by Surah

http
GET /api/v1/ayahs/surah/2

# Get specific ayah from surah
GET /api/v1/ayahs/surah/2/ayah/3

Search Ayahs

http
# Search by English text or translation
GET /api/v1/ayahs/search?q=mercy&skip=0&limit=10

# Search by Arabic text
GET /api/v1/ayahs/search/arabic?q=الرحمن&skip=0&limit=10

# Search by transliteration
GET /api/v1/ayahs/search/transliteration?q=ar-rahman&skip=0&limit=10

Get Ayahs by Juz

http
GET /api/v1/ayahs/juz/1

Get Ayahs Statistics

http
GET /api/v1/ayahs/stats

Response:
{
  "total_ayahs": 6236,
  "total_surahs": 114,
  "total_juz": 30,
  "total_pages": 604
}

# Stats by Surah
GET /api/v1/ayahs/surah/2/stats

5. Rate Limits & Usage Policies

Rate Limiting

Current Limit: 100 requests per minute per IP address for authenticated requests. Public endpoints have a limit of 50 requests per minute.

Rate limit information is included in response headers:

text
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 99
X-RateLimit-Reset: 1614556800

Usage Best Practices

  • •Cache responses locally to reduce API calls
  • •Use pagination (skip/limit) for large datasets
  • •Implement exponential backoff for retries
  • •Batch requests when possible
  • •Monitor X-RateLimit-Remaining header

Error Handling

javascript
# 429 Too Many Requests
HTTP/1.1 429 Too Many Requests
Retry-After: 60

{
  "detail": "Rate limit exceeded. Retry after 60 seconds."
}

# Recommended retry logic
async function makeRequest(url, options = {}) {
  try {
    const response = await fetch(url, options);
    
    if (response.status === 429) {
      const retryAfter = response.headers.get('Retry-After');
      await new Promise(r => setTimeout(r, retryAfter * 1000));
      return makeRequest(url, options);
    }
    
    return response.json();
  } catch (error) {
    console.error('Request failed:', error);
  }
}

6. SDKs & Client Libraries

JavaScript/TypeScript (Browser & Node.js)

javascript
npm install @quranicknowledge/api-sdk

import { QuranicAPI } from '@quranicknowledge/api-sdk';

const api = new QuranicAPI({
  baseUrl: 'https://app.tafheemulquran.net/api/v1',
  token: 'your-jwt-token'
});

// Get ayahs from Surah Al-Fatiha
const ayahs = await api.ayahs.getBySurah(1);
console.log(ayahs);

// Create article
const article = await api.articles.create({
  title: 'My Article',
  content: 'Content here...',
  surah_id: 1
});

Python

python
pip install quranic-api-sdk

from quranic_api import QuranicAPI

api = QuranicAPI(
  base_url='https://app.tafheemulquran.net/api/v1',
    token='your-jwt-token'
)

# Get all surahs
surahs = api.ayahs.get_all(limit=10)

# Search ayahs
results = api.ayahs.search(q='mercy', limit=20)

cURL (No SDK Required)

bash
# Get Surah Al-Fatiha ayahs
curl -X GET \
  'https://app.tafheemulquran.net/api/v1/ayahs/surah/1' \
  -H 'Accept: application/json'

# Create article (requires authentication)
curl -X POST \
  'https://app.tafheemulquran.net/api/v1/articles' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "title": "Article Title",
    "content": "Article content...",
    "surah_id": 1
  }'

7. Contribution Guidelines

Open Source

The Tafheem Research Lab API is open source. We welcome contributions from the community.

Repository link available on request.

How to Contribute

  1. Fork the repository on GitHub
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request with a clear description

Code Standards

  • ✓Follow PEP 8 for Python code
  • ✓Use TypeScript for JavaScript
  • ✓Write unit tests for new features
  • ✓Update documentation alongside code
  • ✓Ensure backward compatibility

Reporting Bugs

Found a bug? Please report it on GitHub Issues with:

  • Clear description of the issue
  • Steps to reproduce
  • Expected vs actual behavior
  • Environment details (OS, API version, etc.)

8. Support & Contact

📧 Email Support

For technical support and API assistance:

support@localhost

💬 Discord Community

Join our developer community:

Community link coming soon.

📖 Documentation

Full API documentation and guides:

https://app.tafheemulquran.net/api/v1/docs

🐛 Issue Tracker

Report bugs and request features:

Issue tracker available on request.

Response Times

  • Critical Issues (API Down):2 hours
  • Bug Reports:24 hours
  • Feature Requests:5 business days

Ready to Build?

Get started with the Tafheem Research Lab API today. Explore the interactive API documentation and begin building amazing applications.