Skip to content

Migrate and Modernize SDK Documentation for Quran Foundation API #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: main
Choose a base branch
from

Conversation

basit3407
Copy link
Collaborator

@basit3407 basit3407 commented Jul 3, 2025

This PR migrates the documentation from the previous SDK (api-js) and updates it for the Quran Foundation Content API.

Key changes:

  • Completely rewrote documentation in /docs to reflect the new API structure and authentication (OAuth2)
  • Added updated Getting Started, Authentication, and Usage Example sections
  • Linked endpoint references to the main API docs at https://api-docs.quran.foundation
  • Included migration notes for users of the old SDK
  • Ensured all documentation is formatted for Docusaurus and builds successfully

Please review and let me know if any further updates are needed!

basit3407 added 30 commits June 24, 2025 11:02
in random verse endpoint

Added missing documentation for existing query parameters supported by the random verse endpoint:

- chapter_number
- page_number
- juz_number
- hizb_number
- rub_el_hizb_number
- ruku_number
- manzil_number

These parameters were already supported in the API but not reflected in the documentation. This update ensures developers are aware of all available filtering options when using the endpoint.
/tafsirs/{resource_id}/by_ayah/{ayah_key}

Fixed the incorrect response schema shown for the /tafsirs/{resource_id}/by_ayah/{ayah_key} endpoint in the docs.

The autogenerated version via <ApiTabs> was causing runtime crashes due to unresolved OpenAPI store references. Since that approach wasn't working despite correct infoPath and operationId setup, we manually wrote the MDX documentation using standard Docusaurus components.

Tested locally – page now renders successfully and reflects the accurate response structure.
list-ayah-tafsirs and regenerate MDX

Updated the OpenAPI schema (v4.json) for the /tafsirs/{resource_id}/by_ayah/{ayah_key} endpoint to ensure the response structure reflects the actual API output.

The previous crash with <ApiTabs> was due to incorrect or incomplete schema context. After fixing the schema, we ran:

- yarn clean-all
- yarn gen-all
- yarn start

The generated docs now render correctly and reflect the accurate response, eliminating the need for manual overrides.
…aceholders-in-v4.json

Fix unrendered model placeholders
…-tokens-in-v4.json

Fix placeholder endpoints
…in-get-todays-plan-api

Fix mushafId param docs
…fields-and-word_fields

Add field reference documentation and links
…g-other-endpoints

docs: link resource references
…ushafid-in-get-todays-plan-api"

This reverts commit c498c43, reversing
changes made to 0969369.
…ation-for-docusaurus

Add JavaScript SDK docs
@basit3407 basit3407 requested a review from osamasayed July 3, 2025 11:00
Copy link

vercel bot commented Jul 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
qf-api-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 3, 2025 11:04am

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates and modernizes the JavaScript SDK documentation for the Quran Foundation API, updating it from the previous api-js SDK to reflect the new API structure and OAuth2 authentication requirements.

  • Adds complete SDK documentation section with authentication, usage examples, and migration guide
  • Updates navigation configuration to include SDK documentation in both sidebar and main navigation
  • Provides comprehensive examples for all major SDK functionality including chapters, verses, audio, resources, and search

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
sidebars.js Adds SDK category to sidebar with authentication, usage, endpoints, and migration pages
docusaurus.config.js Adds SDK navigation item to main navbar
docs/sdk/index.md Provides SDK overview with installation instructions and basic setup
docs/sdk/authentication.md Explains OAuth2 authentication flow and token management
docs/sdk/usage.md Comprehensive usage examples for all SDK methods and utilities
docs/sdk/endpoints.md Reference guide linking to official API documentation
docs/sdk/migration.md Migration guide for users upgrading from the old QuranJS API

const random = await quran.qf.verses.findRandom();
```

Additional helpers include `findByPage`, `findByJuz`, `findByHizb` and `findByRub`.
Copy link
Preview

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Missing comma before 'and' in the list. Should be: 'Additional helpers include findByPage, findByJuz, findByHizb, and findByRub.'

Suggested change
Additional helpers include `findByPage`, `findByJuz`, `findByHizb` and `findByRub`.
Additional helpers include `findByPage`, `findByJuz`, `findByHizb`, and `findByRub`.

Copilot uses AI. Check for mistakes.


If you previously used the `@quranjs/api` SDK against the Quran.com endpoints, switching to the new Quran Foundation API requires a few changes.

1. **Base URLs** – The new SDK defaults to `https://apis.quran.foundation` and `https://oauth2.quran.foundation`. Remove any overrides pointing to quran.com.
Copy link
Preview

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The migration guide should provide specific examples of how to update existing code rather than just describing what needs to change. Consider adding before/after code examples for common migration scenarios.

Suggested change
1. **Base URLs** – The new SDK defaults to `https://apis.quran.foundation` and `https://oauth2.quran.foundation`. Remove any overrides pointing to quran.com.
1. **Base URLs** – The new SDK defaults to `https://apis.quran.foundation` and `https://oauth2.quran.foundation`. Remove any overrides pointing to quran.com.
**Before:**
```javascript
const api = require('@quranjs/api');
api.configure({
baseUrl: 'https://api.quran.com',
});

After:

const api = require('@quran.foundation/api');
api.configure({
    baseUrl: 'https://apis.quran.foundation',
});

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant