### Run Development Server Source: https://github.com/saikothasan/quran-api/blob/main/README.md Starts the development server for the project. ```shellscript npm run dev # or yarn dev ``` -------------------------------- ### Install Dependencies Source: https://github.com/saikothasan/quran-api/blob/main/README.md Installs project dependencies using npm or yarn. ```shellscript npm install # or yarn ``` -------------------------------- ### Fetch All Surahs (JavaScript) Source: https://github.com/saikothasan/quran-api/blob/main/README.md Example of fetching all surahs in English using the Fetch API in JavaScript. ```javascript fetch('https://alquran-api.pages.dev/api/quran?lang=en') .then(response => response.json()) .then(data => { console.log(data); }) .catch(error => { console.error('Error:', error); }); ``` -------------------------------- ### API Documentation Source: https://github.com/saikothasan/quran-api/blob/main/README.md Documentation for the Al-Quran RESTful API, including base URL, endpoints, parameters, and example requests. ```APIDOC Base URL: [https://alquran-api.pages.dev/api/quran](https://alquran-api.pages.dev/api/quran) Endpoints: | Endpoint | Description | Parameters | |----------|-------------|------------| | /api/quran | Get all surahs | `lang` (optional) | | /api/quran/surah/{id} | Get a specific surah | `id` (required), `lang` (optional) | | /api/quran/surah/{id}/verse/{verseId} | Get a specific verse | `id` (required), `verseId` (required), `lang` (optional) | | /api/quran/search | Search the Quran | `q` (required), `lang` (optional) | | /api/quran/languages | Get available languages | None | Language Parameter: All endpoints accept a `lang` query parameter to specify the language. If not specified, English (`en`) is used as the default language. Available language codes: - `ar` - Arabic - `bn` - Bengali - `en` - English - `es` - Spanish - `fr` - French - `id` - Indonesian - `ru` - Russian - `sv` - Swedish - `tr` - Turkish - `ur` - Urdu - `zh` - Chinese - `transliteration` - Transliteration Example Requests: #### Get all surahs in English GET [https://alquran-api.pages.dev/api/quran?lang=en](https://alquran-api.pages.dev/api/quran?lang=en) #### Get Surah Al-Fatihah in Arabic GET [https://alquran-api.pages.dev/api/quran/surah/1?lang=ar](https://alquran-api.pages.dev/api/quran/surah/1?lang=ar) #### Get a specific verse GET [https://alquran-api.pages.dev/api/quran/surah/1/verse/1?lang=en](https://alquran-api.pages.dev/api/quran/surah/1/verse/1?lang=en) #### Search for "mercy" in the Quran GET [https://alquran-api.pages.dev/api/quran/search?q=mercy&lang=en](https://alquran-api.pages.dev/api/quran/search?q=mercy&lang=en) #### Get available languages GET [https://alquran-api.pages.dev/api/quran/languages](https://alquran-api.pages.dev/api/quran/languages) ``` -------------------------------- ### Clone Repository Source: https://github.com/saikothasan/quran-api/blob/main/README.md Clones the Al-Quran API repository from GitHub. ```bash git clone https://github.com/saikothasan/quran-api.git cd quran-api ``` -------------------------------- ### Robots.txt Directives Source: https://github.com/saikothasan/quran-api/blob/main/public/robots.txt Specifies user-agent access and allows all paths for crawling. Includes a sitemap location for search engine indexing. ```APIDOC User-agent: * Allow: / Sitemap: https://alquran-api.pages.dev/sitemap.xml ``` -------------------------------- ### Fetch and Display Surah Data in React Source: https://github.com/saikothasan/quran-api/blob/main/README.md This React component fetches Surah data from the Quran API and displays its transliteration, translation, and verses. It handles loading and error states. Dependencies include React hooks like useState and useEffect. ```javascript import { useState, useEffect } from 'react'; function QuranViewer() { const [surah, setSurah] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { async function fetchSurah() { try { setLoading(true); const response = await fetch( 'https://alquran-api.pages.dev/api/quran/surah/1?lang=en' ); if (!response.ok) { throw new Error('Failed to fetch'); } const data = await response.json(); setSurah(data); } catch (err) { setError(err.message); } finally { setLoading(false); } } fetchSurah(); }, []); if (loading) return
{verse.text}
{verse.translation}