Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/content_apis_versioned/4.0.0/chapter-reciters.api.mdx

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/4.0.0/list-juz-recitation.api.mdx

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/4.0.0/random-verse.api.mdx

Large diffs are not rendered by default.

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/content_apis_versioned/4.0.0/recitation-info.api.mdx

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/content_apis_versioned/4.0.0/recitations.api.mdx

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/4.0.0/verses-by-range.api.mdx

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/4.0.0/verses-by-verse-key.api.mdx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/audio-reciter-lookup.api.mdx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/audio-reciter-timestamp.api.mdx

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/content_apis_versioned/chapter-reciters.api.mdx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/list-ayah-recitation.api.mdx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/list-hizb-recitation.api.mdx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/list-juz-recitation.api.mdx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/list-manzil-recitation.api.mdx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/list-page-recitation.api.mdx

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/list-ruku-recitation.api.mdx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/list-surah-recitation.api.mdx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/random-verse.api.mdx

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/content_apis_versioned/recitation-audio-files.api.mdx

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/content_apis_versioned/recitation-info.api.mdx

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/content_apis_versioned/recitations.api.mdx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/verses-by-chapter-number.api.mdx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/verses-by-hizb-number.api.mdx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/verses-by-juz-number.api.mdx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/verses-by-manzil-number.api.mdx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/verses-by-page-number.api.mdx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/verses-by-range.api.mdx

Large diffs are not rendered by default.

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/content_apis_versioned/verses-by-rub-el-hizb-number.api.mdx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/verses-by-ruku-number.api.mdx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/content_apis_versioned/verses-by-verse-key.api.mdx

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions docs/sdk/javascript/audio.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ slug: /sdk/javascript/audio

import Link from "@docusaurus/Link";

The Audio API provides access to audio recitations including chapter audio and verse-by-verse audio with timing.
The Audio API provides access to recitation audio from the authenticated Content API, including chapter audio and verse-by-verse audio with optional timing data.

## Choose the Right Audio Source

| Use case | Fetch from | Returned shape | Notes |
| --- | --- | --- | --- |
| Single-word pronunciation | `word.audioUrl` from the [Verses API](/docs/sdk/javascript/verses) | Relative `wbw/...` asset path | Resolve it against `https://audio.qurancdn.com/` before playing it in the browser. |
| Chapter playback | `client.audio.findAllChapterRecitations()` or `client.audio.findChapterRecitationById()` | Full chapter `audioUrl` | Use this for continuous chapter playback. |
| Ayah playback with timing | `client.audio.findVerseRecitationsByChapter()` or `client.audio.findVerseRecitationsByKey()` | Verse recitation `url` plus optional `segments` | Use this for ayah recitations and highlighting. This is distinct from `word.audioUrl`. |

## Chapter Recitations

Expand All @@ -33,7 +41,7 @@ console.log(recitations[0]);
| `chapterId` | `number` | Surah that the audio recitation belongs to. |
| `fileSize` | `number` | File size in bytes. |
| `format` | `string` | Audio format, typically `mp3`. |
| `audioUrl` | `string` | Download URL for the chapter recitation. |
| `audioUrl` | `string` | Full chapter recitation URL returned by the Content API. |

### Get Specific Chapter

Expand Down Expand Up @@ -65,13 +73,13 @@ audioFiles.forEach((audio) => {
| Field | Type | Notes |
| ----------- | ----------- | ------------------------------------------------- |
| `verseKey` | `string` | Verse identifier such as `2:255`. |
| `url` | `string` | Direct URL to the verse audio file. |
| `url` | `string` | Verse recitation URL or path returned by the Content API. Distinct from `word.audioUrl`. |
| `id` | `number` | Unique identifier for the verse recitation. |
| `chapterId` | `number` | Surah that the verse belongs to. |
| `segments` | `Segment[]` | Optional timing metadata for word-level playback. |
| `format` | `string` | Audio format, e.g. `mp3`. |

`Segment` entries include the timestamp ranges (`start`, `end`) that power word-level playback.
`Segment` entries include the timestamp ranges (`start`, `end`) that power highlighting and seek within the recitation.

### By Verse Key

Expand Down
2 changes: 2 additions & 0 deletions docs/sdk/javascript/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import TabItem from "@theme/TabItem";

The official JavaScript/TypeScript SDK for the Quran.Foundation API. Works in Node.js and browsers.

> Note: The SDK can run in browser code, but keep `clientSecret` on your server and make authenticated Content API calls from a backend or server-side runtime. Public word-by-word audio playback uses the separate `word.audioUrl` asset path described in the [Verses API](/docs/sdk/javascript/verses) and the backend-safe auth flow described in the [Content APIs Quickstart](/docs/quickstart/).

<p>
<a
href="https://www.npmjs.com/package/@quranjs/api"
Expand Down
25 changes: 25 additions & 0 deletions docs/sdk/javascript/verses.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,30 @@ const verse = await client.verses.findByKey("1:1", {
});
```

Requesting `words: true` can include `word.audioUrl` for each word. That value is a relative word-by-word asset path such as `wbw/001_001_001.mp3`, not a `/content/api/v4/...` endpoint.

### Word Audio Paths

```ts
const verse = await client.verses.findByKey("1:1", {
words: true,
wordFields: {
audio: true,
location: true,
},
});

const firstWord = verse.words?.[0];
const wordAudioUrl = firstWord
? new URL(
firstWord.audioUrl.replace(/^\/+/, ""),
"https://audio.qurancdn.com/",
).toString()
: null;
```

Use `word.audioUrl` for single-word pronunciation playback. For chapter or ayah recitations, and for timing `segments`, use the [Audio API](/docs/sdk/javascript/audio) instead.

### With Tafsir

```ts
Expand Down Expand Up @@ -132,6 +156,7 @@ const random = await client.verses.findRandom({
const verse = await client.verses.findByKey("1:1", {
words: true,
wordFields: {
audio: true,
textUthmani: true,
verseKey: true,
location: true,
Expand Down
119 changes: 62 additions & 57 deletions openAPI/content/v4.json

Large diffs are not rendered by default.