@quranjs/api 1.8.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1008 @@
1
+ /**
2
+ * Maps chapter number to verse count
3
+ */
4
+ declare const versesMapping: {
5
+ readonly 1: 7;
6
+ readonly 2: 286;
7
+ readonly 3: 200;
8
+ readonly 4: 176;
9
+ readonly 5: 120;
10
+ readonly 6: 165;
11
+ readonly 7: 206;
12
+ readonly 8: 75;
13
+ readonly 9: 129;
14
+ readonly 10: 109;
15
+ readonly 11: 123;
16
+ readonly 12: 111;
17
+ readonly 13: 43;
18
+ readonly 14: 52;
19
+ readonly 15: 99;
20
+ readonly 16: 128;
21
+ readonly 17: 111;
22
+ readonly 18: 110;
23
+ readonly 19: 98;
24
+ readonly 20: 135;
25
+ readonly 21: 112;
26
+ readonly 22: 78;
27
+ readonly 23: 118;
28
+ readonly 24: 64;
29
+ readonly 25: 77;
30
+ readonly 26: 227;
31
+ readonly 27: 93;
32
+ readonly 28: 88;
33
+ readonly 29: 69;
34
+ readonly 30: 60;
35
+ readonly 31: 34;
36
+ readonly 32: 30;
37
+ readonly 33: 73;
38
+ readonly 34: 54;
39
+ readonly 35: 45;
40
+ readonly 36: 83;
41
+ readonly 37: 182;
42
+ readonly 38: 88;
43
+ readonly 39: 75;
44
+ readonly 40: 85;
45
+ readonly 41: 54;
46
+ readonly 42: 53;
47
+ readonly 43: 89;
48
+ readonly 44: 59;
49
+ readonly 45: 37;
50
+ readonly 46: 35;
51
+ readonly 47: 38;
52
+ readonly 48: 29;
53
+ readonly 49: 18;
54
+ readonly 50: 45;
55
+ readonly 51: 60;
56
+ readonly 52: 49;
57
+ readonly 53: 62;
58
+ readonly 54: 55;
59
+ readonly 55: 78;
60
+ readonly 56: 96;
61
+ readonly 57: 29;
62
+ readonly 58: 22;
63
+ readonly 59: 24;
64
+ readonly 60: 13;
65
+ readonly 61: 14;
66
+ readonly 62: 11;
67
+ readonly 63: 11;
68
+ readonly 64: 18;
69
+ readonly 65: 12;
70
+ readonly 66: 12;
71
+ readonly 67: 30;
72
+ readonly 68: 52;
73
+ readonly 69: 52;
74
+ readonly 70: 44;
75
+ readonly 71: 28;
76
+ readonly 72: 28;
77
+ readonly 73: 20;
78
+ readonly 74: 56;
79
+ readonly 75: 40;
80
+ readonly 76: 31;
81
+ readonly 77: 50;
82
+ readonly 78: 40;
83
+ readonly 79: 46;
84
+ readonly 80: 42;
85
+ readonly 81: 29;
86
+ readonly 82: 19;
87
+ readonly 83: 36;
88
+ readonly 84: 25;
89
+ readonly 85: 22;
90
+ readonly 86: 17;
91
+ readonly 87: 19;
92
+ readonly 88: 26;
93
+ readonly 89: 30;
94
+ readonly 90: 20;
95
+ readonly 91: 15;
96
+ readonly 92: 21;
97
+ readonly 93: 11;
98
+ readonly 94: 8;
99
+ readonly 95: 8;
100
+ readonly 96: 19;
101
+ readonly 97: 5;
102
+ readonly 98: 8;
103
+ readonly 99: 8;
104
+ readonly 100: 11;
105
+ readonly 101: 11;
106
+ readonly 102: 8;
107
+ readonly 103: 3;
108
+ readonly 104: 9;
109
+ readonly 105: 5;
110
+ readonly 106: 4;
111
+ readonly 107: 7;
112
+ readonly 108: 3;
113
+ readonly 109: 6;
114
+ readonly 110: 3;
115
+ readonly 111: 5;
116
+ readonly 112: 4;
117
+ readonly 113: 5;
118
+ readonly 114: 6;
119
+ };
120
+
121
+ type _NumbersFrom0ToN<Nr extends number> = Nr extends Nr ? number extends Nr ? number : Nr extends 0 ? never : _NumbersFrom0ToNRec<Nr, [], 0> : never;
122
+ type _NumbersFrom0ToNRec<Nr extends number, Counter extends unknown[], Accumulator extends number> = Counter["length"] extends Nr ? Accumulator : _NumbersFrom0ToNRec<Nr, [
123
+ unknown,
124
+ ...Counter
125
+ ], Accumulator | Counter["length"]>;
126
+ type NumberRange<Start extends number, End extends number> = Exclude<_NumbersFrom0ToN<End>, _NumbersFrom0ToN<Start>>;
127
+ type NumberUnionToString<TType> = TType extends number ? `${TType}` : TType;
128
+ /**
129
+ * Builds a tuple with a length equal to the provided number literal.
130
+ * Used for type-level arithmetic.
131
+ */
132
+ type BuildTuple<TLength extends number, TAccumulator extends unknown[] = []> = TAccumulator["length"] extends TLength ? TAccumulator : BuildTuple<TLength, [...TAccumulator, unknown]>;
133
+ /**
134
+ * Increments a numeric literal type by 1.
135
+ */
136
+ type Increment<TNumber extends number> = [
137
+ ...BuildTuple<TNumber>,
138
+ unknown
139
+ ]["length"];
140
+
141
+ /**
142
+ * A `VerseKey` is a string literal in the form `${chapter}:${verse}` where:
143
+ * - `chapter` is a valid chapter id from `versesMapping`
144
+ * - `verse` is within the range 1..(verseCount for that chapter)
145
+ */
146
+ type VerseKey = {
147
+ [TChapter in keyof typeof versesMapping]: `${TChapter}:${NumberRange<1, Increment<(typeof versesMapping)[TChapter]>>}`;
148
+ }[keyof typeof versesMapping];
149
+
150
+ type ChapterId = keyof typeof versesMapping | NumberUnionToString<keyof typeof versesMapping>;
151
+
152
+ type _HizbNumber = NumberRange<1, 61>;
153
+ type HizbNumber = _HizbNumber | NumberUnionToString<_HizbNumber>;
154
+
155
+ type _JuzNumber = NumberRange<1, 31>;
156
+ type JuzNumber = _JuzNumber | NumberUnionToString<_JuzNumber>;
157
+
158
+ type _PageNumber = NumberRange<1, 605>;
159
+ type PageNumber = _PageNumber | NumberUnionToString<_PageNumber>;
160
+
161
+ type _RubNumber = NumberRange<1, 241>;
162
+ type RubNumber = _RubNumber | NumberUnionToString<_RubNumber>;
163
+
164
+ interface Translation {
165
+ id?: number;
166
+ text: string;
167
+ resourceId: number;
168
+ resourceName?: string;
169
+ verseId?: number;
170
+ languageId?: number;
171
+ languageName?: string;
172
+ verseKey?: VerseKey;
173
+ chapterId?: number;
174
+ verseNumber?: number;
175
+ juzNumber?: number;
176
+ hizbNumber?: number;
177
+ rubNumber?: number;
178
+ pageNumber?: number;
179
+ }
180
+
181
+ interface Transliteration {
182
+ languageName?: string;
183
+ text?: string;
184
+ }
185
+
186
+ declare enum CharType {
187
+ Word = "word",
188
+ End = "end",
189
+ Pause = "pause",
190
+ Sajdah = "sajdah",
191
+ RubElHizb = "rub-el-hizb"
192
+ }
193
+ interface Word {
194
+ id?: number;
195
+ position: number;
196
+ audioUrl: string;
197
+ charTypeName: CharType;
198
+ codeV1?: string;
199
+ codeV2?: string;
200
+ pageNumber?: number;
201
+ lineNumber?: number;
202
+ text?: string;
203
+ textUthmani?: string;
204
+ textIndopak?: string;
205
+ textImlaei?: string;
206
+ translation: Translation;
207
+ transliteration: Transliteration;
208
+ location?: string;
209
+ verseKey?: VerseKey;
210
+ }
211
+
212
+ interface SearchResponse {
213
+ search: {
214
+ query: string;
215
+ totalResults: number;
216
+ currentPage: number;
217
+ totalPages: number;
218
+ results?: {
219
+ verseKey: string;
220
+ verse_id: number;
221
+ text: string;
222
+ highlighted: string;
223
+ words: Word[];
224
+ translations: Translation[];
225
+ }[];
226
+ };
227
+ }
228
+
229
+ /**
230
+ * Segment structure is [wordFrom, wordTo, timeFrom, timeTo] time is in ms
231
+ */
232
+ type Segment = [number, number, number, number];
233
+
234
+ interface ChapterRecitation {
235
+ id: number;
236
+ chapterId: number;
237
+ fileSize: number;
238
+ format: string;
239
+ audioUrl: string;
240
+ }
241
+ interface VerseRecitation {
242
+ verseKey: VerseKey;
243
+ url: string;
244
+ id?: number;
245
+ chapterId?: number;
246
+ segments?: Segment[];
247
+ format?: string;
248
+ }
249
+
250
+ interface AudioResponse {
251
+ url?: string;
252
+ duration?: number;
253
+ format?: string;
254
+ verseKey: string;
255
+ segments?: Segment[];
256
+ }
257
+
258
+ interface TranslatedName {
259
+ name: string;
260
+ languageName: string;
261
+ }
262
+
263
+ interface Chapter {
264
+ id: number;
265
+ versesCount: number;
266
+ bismillahPre: boolean;
267
+ revelationOrder: number;
268
+ revelationPlace: string;
269
+ pages: Array<number>;
270
+ nameComplex: string;
271
+ nameSimple: string;
272
+ transliteratedName: string;
273
+ nameArabic: string;
274
+ translatedName: TranslatedName;
275
+ }
276
+
277
+ interface ChapterInfo {
278
+ id: number;
279
+ chapterId: number;
280
+ text: string;
281
+ shortText: string;
282
+ source: string;
283
+ languageName?: string;
284
+ }
285
+
286
+ interface Footnote {
287
+ id: number | string;
288
+ text: string;
289
+ languageName?: string;
290
+ languageId?: number;
291
+ }
292
+
293
+ interface Reciter {
294
+ id: number;
295
+ name: string;
296
+ recitationStyle: string;
297
+ relativePath: string;
298
+ profilePicture?: string;
299
+ coverImage?: string;
300
+ bio?: string;
301
+ qirat?: {
302
+ languageName: string;
303
+ name: string;
304
+ };
305
+ style?: {
306
+ languageName: string;
307
+ name: string;
308
+ };
309
+ translatedName?: {
310
+ languageName: string;
311
+ name: string;
312
+ };
313
+ }
314
+
315
+ interface Tafsir {
316
+ id?: number;
317
+ resourceId?: number;
318
+ text?: string;
319
+ resourceName?: string;
320
+ languageName?: string;
321
+ }
322
+
323
+ interface TafsirInfo {
324
+ id?: number;
325
+ name?: string;
326
+ authorName?: string;
327
+ slug?: string;
328
+ languageName?: string;
329
+ translatedName: TranslatedName;
330
+ }
331
+
332
+ interface Verse {
333
+ id: number;
334
+ verseNumber: number;
335
+ verseKey: VerseKey;
336
+ chapterId?: number | string;
337
+ pageNumber: number;
338
+ juzNumber: number;
339
+ hizbNumber: number;
340
+ rubElHizbNumber: number;
341
+ words?: Word[];
342
+ textUthmani?: string;
343
+ textUthmaniSimple?: string;
344
+ textUthmaniTajweed?: string;
345
+ textImlaei?: string;
346
+ textImlaeiSimple?: string;
347
+ textIndopak?: string;
348
+ textIndopakNastaleeq?: string;
349
+ sajdahNumber: null;
350
+ imageUrl?: string;
351
+ imageWidth?: number;
352
+ v1Page?: number;
353
+ v2Page?: number;
354
+ codeV1?: string;
355
+ codeV2?: string;
356
+ translations?: Translation[];
357
+ tafsirs?: Tafsir[];
358
+ audio?: AudioResponse;
359
+ }
360
+
361
+ interface Juz {
362
+ id: number;
363
+ juzNumber: number;
364
+ verseMapping: Record<number, string>;
365
+ firstVerseId: number;
366
+ lastVerseId: number;
367
+ versesCount: number;
368
+ }
369
+
370
+ interface Pagination {
371
+ perPage: number;
372
+ currentPage: number;
373
+ nextPage: number;
374
+ totalPages: number;
375
+ totalRecords: number;
376
+ }
377
+
378
+ interface RecitationResource {
379
+ id?: number;
380
+ reciterName?: string;
381
+ style?: string;
382
+ translatedName?: TranslatedName;
383
+ }
384
+ interface RecitationInfoResource {
385
+ id?: number;
386
+ info?: string;
387
+ }
388
+ interface TranslationResource {
389
+ id?: number;
390
+ name?: string;
391
+ authorName?: string;
392
+ slug?: string;
393
+ languageName?: string;
394
+ translatedName?: TranslatedName;
395
+ }
396
+ interface TranslationInfoResource {
397
+ id?: number;
398
+ info?: string;
399
+ }
400
+ interface TafsirResource {
401
+ id?: number;
402
+ name?: string;
403
+ authorName?: string;
404
+ slug?: string;
405
+ languageName?: string;
406
+ translatedName?: TranslatedName;
407
+ }
408
+ interface TafsirInfoResource {
409
+ id?: number;
410
+ info?: string;
411
+ }
412
+ interface RecitationStylesResource {
413
+ mujawwad: string;
414
+ murattal: string;
415
+ muallim: string;
416
+ }
417
+ interface LanguageResource {
418
+ id?: number;
419
+ name?: string;
420
+ nativeName?: string;
421
+ isoCode?: string;
422
+ direction?: string;
423
+ translatedNames?: TranslatedName[];
424
+ }
425
+ interface ChapterInfoResource {
426
+ id?: number;
427
+ name?: string;
428
+ authorName?: string;
429
+ slug?: string;
430
+ languageName?: string;
431
+ translatedName?: TranslatedName;
432
+ }
433
+ interface VerseMediaResource {
434
+ id?: number;
435
+ name?: string;
436
+ authorName?: string;
437
+ languageName?: string;
438
+ }
439
+ interface ChapterReciterResource {
440
+ id: number;
441
+ name: string;
442
+ arabicName?: string;
443
+ relativePath?: string;
444
+ format?: string;
445
+ filesSize?: number;
446
+ }
447
+
448
+ interface SearchResult {
449
+ verseKey: VerseKey;
450
+ verseId: number;
451
+ text: string;
452
+ highlighted?: string;
453
+ words: Word[];
454
+ translations: Translation[];
455
+ }
456
+
457
+ type ApiParams = Record<string, string | number | boolean | unknown[] | undefined | Record<string, boolean>>;
458
+ /**
459
+ * Base parameters that are common across most API endpoints
460
+ */
461
+ interface BaseApiParams extends ApiParams {
462
+ /** Language for the response */
463
+ language?: Language;
464
+ }
465
+ /**
466
+ * Pagination parameters
467
+ */
468
+ interface PaginationParams extends ApiParams {
469
+ /** Page number for pagination */
470
+ page?: number;
471
+ /** Number of items per page */
472
+ perPage?: number;
473
+ }
474
+ /**
475
+ * Search parameters
476
+ */
477
+ interface SearchParams extends BaseApiParams {
478
+ /** Number of results to return */
479
+ size?: number;
480
+ /** Page number for pagination */
481
+ page?: number;
482
+ }
483
+
484
+ /**
485
+ * Custom fetcher function type that matches the native fetch API
486
+ */
487
+ type CustomFetcher = typeof fetch;
488
+ interface QuranClientConfig {
489
+ /** Client ID for authentication */
490
+ clientId: string;
491
+ /** Client secret for authentication */
492
+ clientSecret: string;
493
+ /** Base URL for content APIs */
494
+ contentBaseUrl?: string;
495
+ /** Base URL for authentication */
496
+ authBaseUrl?: string;
497
+ /** Custom fetch implementation */
498
+ fetch?: CustomFetcher;
499
+ /** Default parameters for all API calls */
500
+ defaults?: Partial<BaseApiParams>;
501
+ }
502
+ interface CachedToken {
503
+ value: string;
504
+ expiresAt: number;
505
+ }
506
+ interface TokenResponse {
507
+ access_token: string;
508
+ expires_in: number;
509
+ }
510
+
511
+ declare enum Language {
512
+ ARABIC = "ar",
513
+ ENGLISH = "en",
514
+ URDU = "ur",
515
+ BENGALI = "bn",
516
+ TURKISH = "tr",
517
+ SPANISH = "es",
518
+ GERMAN = "de",
519
+ BOSNIAN = "bs",
520
+ RUSSIAN = "ru",
521
+ ALBANIAN_AL = "al",
522
+ FRENCH = "fr",
523
+ DUTCH = "nl",
524
+ TAMIL = "ta",
525
+ TAJIK = "tg",
526
+ INDONESIAN = "id",
527
+ UZBEK = "uz",
528
+ VIETNAMESE = "vi",
529
+ CHINESE = "zh",
530
+ ITALIAN = "it",
531
+ JAPANESE = "ja",
532
+ MALAYALAM = "ml",
533
+ AMHARIC = "am",
534
+ KAZAKH = "kk",
535
+ PORTUGUESE = "pt",
536
+ TAGALOG = "tl",
537
+ THAI = "th",
538
+ KOREAN = "ko",
539
+ HINDI = "hi",
540
+ KURDISH = "ku",
541
+ HAUSA = "ha",
542
+ AZERI = "az",
543
+ SWAHILI = "sw",
544
+ PERSIAN = "fa",
545
+ SERBIAN = "sr",
546
+ MARANAO = "mrn",
547
+ AMAZIGH = "zgh",
548
+ ASSAMESE = "as",
549
+ BULGARIAN = "bg",
550
+ CHECHEN = "ce",
551
+ CZECH = "cs",
552
+ DIVEHI = "dv",
553
+ FINNISH = "fi",
554
+ GUJAARATI = "gu",
555
+ HEBREW = "he",
556
+ GEORGIAN = "ka",
557
+ CENTRAL_KHMER = "km",
558
+ GANDA = "lg",
559
+ MARATHI = "mr",
560
+ YORUBA = "yo",
561
+ MALAY = "ms",
562
+ NEPALI = "ne",
563
+ SWEDISH = "sv",
564
+ TELUGU = "te",
565
+ TATAR = "tt",
566
+ UYGHUR = "ug",
567
+ UKRAINIAN = "uk",
568
+ NORWEGIAN = "no",
569
+ OROMO = "om",
570
+ POLISH = "pl",
571
+ PASHTO = "ps",
572
+ ROMANIAN = "ro",
573
+ SINDHI = "sd",
574
+ NORTHERN_SAMI = "se",
575
+ SINHALA = "si",
576
+ SOMALI = "so",
577
+ ALBANIAN_SQ = "sq"
578
+ }
579
+ declare enum QuranFont {
580
+ MadaniV1 = "code_v1",
581
+ MadaniV2 = "code_v2",
582
+ Uthmani = "text_uthmani"
583
+ }
584
+ type VerseField = "chapterId" | "textUthmani" | "textUthmaniSimple" | "textImlaei" | "textImlaeiSimple" | "textIndopak" | "textIndopakNastaleeq" | "textUthmaniTajweed" | "imageUrl" | "imageWidth" | "codeV1" | "codeV2" | "v1Page" | "v2Page";
585
+ type WordField = "v1Page" | "v2Page" | "textUthmani" | "textImlaei" | "textIndopak" | "verseKey" | "location" | "codeV1" | "codeV2";
586
+ type TranslationField = "resourceName" | "verseId" | "languageId" | "languageName" | "verseKey" | "chapterId" | "verseNumber" | "juzNumber" | "hizbNumber" | "rubNumber" | "pageNumber";
587
+ type VerseRecitationField = "id" | "chapterId" | "segments" | "format";
588
+
589
+ type Config = Required<Pick<QuranClientConfig, "contentBaseUrl" | "authBaseUrl">> & Omit<QuranClientConfig, "contentBaseUrl" | "authBaseUrl">;
590
+ /**
591
+ * Handles HTTP requests with authentication for the Quran API
592
+ */
593
+ declare class QuranFetcher {
594
+ private config;
595
+ private cachedToken;
596
+ constructor(config: Config);
597
+ /**
598
+ * Update the configuration
599
+ */
600
+ updateConfig(config: Config): void;
601
+ getFetch(): CustomFetcher;
602
+ private doFetch;
603
+ /**
604
+ * Get access token for API authentication
605
+ */
606
+ private getAccessToken;
607
+ /**
608
+ * Clear cached token (useful for testing or forcing re-authentication)
609
+ */
610
+ clearCachedToken(): void;
611
+ /**
612
+ * Make URL with base URL and query parameters
613
+ */
614
+ private makeUrl;
615
+ /**
616
+ * Make authenticated HTTP request
617
+ */
618
+ fetch<T extends object>(url: string, params?: ApiParams): Promise<T>;
619
+ }
620
+
621
+ type GetChapterRecitationOptions = BaseApiParams;
622
+ type GetVerseRecitationOptions = BaseApiParams & {
623
+ fields?: Partial<Record<VerseRecitationField, boolean>>;
624
+ };
625
+ /**
626
+ * Audio API methods
627
+ */
628
+ declare class QuranAudio {
629
+ private fetcher;
630
+ constructor(fetcher: QuranFetcher);
631
+ /**
632
+ * Get all chapter recitations for specific reciter
633
+ * @param {string} reciterId
634
+ * @param {GetChapterRecitationOptions} options
635
+ * @example
636
+ * client.audio.findAllChapterRecitations('2')
637
+ */
638
+ findAllChapterRecitations(reciterId: string, options?: GetChapterRecitationOptions): Promise<ChapterRecitation[]>;
639
+ /**
640
+ * Get a specific chapter recitation by reciter and chapter
641
+ * @param {string} reciterId
642
+ * @param {ChapterId} chapterId
643
+ * @param {GetChapterRecitationOptions} options
644
+ * @example
645
+ * client.audio.findChapterRecitationById('2', '1')
646
+ */
647
+ findChapterRecitationById(reciterId: string, chapterId: ChapterId, options?: GetChapterRecitationOptions): Promise<ChapterRecitation>;
648
+ /**
649
+ * Get verse recitations by chapter
650
+ * @param {ChapterId} chapterId
651
+ * @param {string} recitationId
652
+ * @param {GetVerseRecitationOptions} options
653
+ * @example
654
+ * client.audio.findVerseRecitationsByChapter('1', '2')
655
+ */
656
+ findVerseRecitationsByChapter(chapterId: ChapterId, recitationId: string, options?: GetVerseRecitationOptions): Promise<{
657
+ audioFiles: VerseRecitation[];
658
+ pagination: Pagination;
659
+ }>;
660
+ /**
661
+ * Get verse recitations by verse key
662
+ * @param {VerseKey} key
663
+ * @param {string} recitationId
664
+ * @param {GetVerseRecitationOptions} options
665
+ * @example
666
+ * client.audio.findVerseRecitationsByKey('1:1', '2')
667
+ */
668
+ findVerseRecitationsByKey(key: VerseKey, recitationId: string, options?: GetVerseRecitationOptions): Promise<{
669
+ audioFiles: VerseRecitation[];
670
+ pagination: Pagination;
671
+ }>;
672
+ }
673
+
674
+ type GetChapterOptions = BaseApiParams;
675
+ /**
676
+ * Chapters API methods
677
+ */
678
+ declare class QuranChapters {
679
+ private fetcher;
680
+ constructor(fetcher: QuranFetcher);
681
+ /**
682
+ * Get all chapters.
683
+ * @description https://api-docs.quran.com/docs/quran.com_versioned/4.0.0/list-chapters
684
+ * @param {GetChapterOptions} options
685
+ * @example
686
+ * client.chapters.findAll()
687
+ */
688
+ findAll(options?: GetChapterOptions): Promise<Chapter[]>;
689
+ /**
690
+ * Get chapter by id.
691
+ * @description https://api-docs.quran.com/docs/quran.com_versioned/4.0.0/get-chapter
692
+ * @param {ChapterId} id chapter id, minimum 1, maximum 114
693
+ * @param {GetChapterOptions} options
694
+ * @example
695
+ * client.chapters.findById('1')
696
+ * client.chapters.findById('114')
697
+ */
698
+ findById(id: ChapterId, options?: GetChapterOptions): Promise<Chapter>;
699
+ /**
700
+ * Get chapter info by id.
701
+ * @description https://api-docs.quran.com/docs/quran.com_versioned/4.0.0/get-chapter-info
702
+ * @param {ChapterId} id chapter id, minimum 1, maximum 114
703
+ * @param {GetChapterOptions} options
704
+ * @example
705
+ * client.chapters.findInfoById('1')
706
+ * client.chapters.findInfoById('114')
707
+ */
708
+ findInfoById(id: ChapterId, options?: GetChapterOptions): Promise<ChapterInfo>;
709
+ }
710
+
711
+ /**
712
+ * Juzs API methods
713
+ */
714
+ declare class QuranJuzs {
715
+ private fetcher;
716
+ constructor(fetcher: QuranFetcher);
717
+ /**
718
+ * Get All Juzs
719
+ * @description https://api-docs.quran.com/docs/quran.com_versioned/4.0.0/juzs
720
+ * @example
721
+ * client.juzs.findAll()
722
+ */
723
+ findAll(): Promise<Juz[]>;
724
+ }
725
+
726
+ type GetResourceOptions = BaseApiParams;
727
+ /**
728
+ * Resources API methods
729
+ */
730
+ declare class QuranResources {
731
+ private fetcher;
732
+ constructor(fetcher: QuranFetcher);
733
+ /**
734
+ * Get all recitations.
735
+ * @param {GetResourceOptions} options
736
+ * @example
737
+ * client.resources.findAllRecitations()
738
+ */
739
+ findAllRecitations(options?: GetResourceOptions): Promise<RecitationResource[]>;
740
+ /**
741
+ * Get all translations.
742
+ * @param {GetResourceOptions} options
743
+ * @example
744
+ * client.resources.findAllTranslations()
745
+ */
746
+ findAllTranslations(options?: GetResourceOptions): Promise<TranslationResource[]>;
747
+ /**
748
+ * Get all tafsirs.
749
+ * @param {GetResourceOptions} options
750
+ * @example
751
+ * client.resources.findAllTafsirs()
752
+ */
753
+ findAllTafsirs(options?: GetResourceOptions): Promise<TafsirResource[]>;
754
+ /**
755
+ * Get all languages.
756
+ * @param {GetResourceOptions} options
757
+ * @example
758
+ * client.resources.findAllLanguages()
759
+ */
760
+ findAllLanguages(options?: GetResourceOptions): Promise<LanguageResource[]>;
761
+ /**
762
+ * Get recitation info by id.
763
+ * @param {string} id recitation id
764
+ * @param {GetResourceOptions} options
765
+ * @example
766
+ * client.resources.findRecitationInfo('1')
767
+ */
768
+ findRecitationInfo(id: string, options?: GetResourceOptions): Promise<RecitationInfoResource>;
769
+ /**
770
+ * Get translation info by id.
771
+ * @param {string} id translation id
772
+ * @param {GetResourceOptions} options
773
+ * @example
774
+ * client.resources.findTranslationInfo('131')
775
+ */
776
+ findTranslationInfo(id: string, options?: GetResourceOptions): Promise<TranslationInfoResource>;
777
+ /**
778
+ * Get tafsir info by id.
779
+ * @param {string} id tafsir id
780
+ * @param {GetResourceOptions} options
781
+ * @example
782
+ * client.resources.findTafsirInfo('171')
783
+ */
784
+ findTafsirInfo(id: string, options?: GetResourceOptions): Promise<TafsirInfoResource>;
785
+ /**
786
+ * Get all chapter infos.
787
+ * @param {GetResourceOptions} options
788
+ * @example
789
+ * client.resources.findAllChapterInfos()
790
+ */
791
+ findAllChapterInfos(options?: GetResourceOptions): Promise<ChapterInfoResource[]>;
792
+ /**
793
+ * Get all chapter reciters.
794
+ * @param {GetResourceOptions} options
795
+ * @example
796
+ * client.resources.findAllChapterReciters()
797
+ */
798
+ findAllChapterReciters(options?: GetResourceOptions): Promise<ChapterReciterResource[]>;
799
+ /**
800
+ * Get all recitation styles.
801
+ * @param {GetResourceOptions} options
802
+ * @example
803
+ * client.resources.findAllRecitationStyles()
804
+ */
805
+ findAllRecitationStyles(options?: GetResourceOptions): Promise<RecitationStylesResource>;
806
+ /**
807
+ * Get verse media.
808
+ * @param {GetResourceOptions} options
809
+ * @example
810
+ * client.resources.findVerseMedia()
811
+ */
812
+ findVerseMedia(options?: GetResourceOptions): Promise<VerseMediaResource>;
813
+ }
814
+
815
+ type SearchOptions = SearchParams;
816
+ /**
817
+ * Search API methods
818
+ */
819
+ declare class QuranSearch {
820
+ private fetcher;
821
+ constructor(fetcher: QuranFetcher);
822
+ /**
823
+ * Search
824
+ * @description https://api-docs.quran.com/docs/quran.com_versioned/4.0.0/search
825
+ * @param {string} q search query
826
+ * @param {SearchOptions} options
827
+ * @example
828
+ * client.search.search('نور')
829
+ * client.search.search('نور', { language: Language.ENGLISH })
830
+ * client.search.search('نور', { language: Language.ENGLISH, size: 10 })
831
+ * client.search.search('نور', { language: Language.ENGLISH, page: 2 })
832
+ */
833
+ search(q: string, options?: SearchOptions): Promise<SearchResponse["search"]>;
834
+ }
835
+
836
+ type GetVerseOptions = BaseApiParams & PaginationParams & {
837
+ reciter?: string | number;
838
+ words?: boolean;
839
+ translations?: string[] | number[];
840
+ tafsirs?: string[] | number[];
841
+ wordFields?: Partial<Record<WordField, boolean>>;
842
+ translationFields?: Partial<Record<TranslationField, boolean>>;
843
+ fields?: Partial<Record<VerseField, boolean>>;
844
+ };
845
+ /**
846
+ * Verses API methods
847
+ */
848
+ declare class QuranVerses {
849
+ private fetcher;
850
+ constructor(fetcher: QuranFetcher);
851
+ /**
852
+ * Get a specific verse by its key.
853
+ * @param {VerseKey} key verse key in format "chapter:verse" (e.g., "1:1")
854
+ * @param {GetVerseOptions} options
855
+ * @example
856
+ * client.verses.findByKey('1:1')
857
+ * client.verses.findByKey('2:255')
858
+ */
859
+ findByKey(key: VerseKey, options?: GetVerseOptions): Promise<Verse>;
860
+ /**
861
+ * Get verses by chapter.
862
+ * @param {ChapterId} id chapter id, minimum 1, maximum 114
863
+ * @param {GetVerseOptions} options
864
+ * @example
865
+ * client.verses.findByChapter('1')
866
+ */
867
+ findByChapter(id: ChapterId, options?: GetVerseOptions): Promise<Verse[]>;
868
+ /**
869
+ * Get verses by page number.
870
+ * @param {PageNumber} page page number
871
+ * @param {GetVerseOptions} options
872
+ * @example
873
+ * client.verses.findByPage('1')
874
+ */
875
+ findByPage(page: PageNumber, options?: GetVerseOptions): Promise<Verse[]>;
876
+ /**
877
+ * Get verses by juz number.
878
+ * @param {JuzNumber} juz juz number
879
+ * @param {GetVerseOptions} options
880
+ * @example
881
+ * client.verses.findByJuz('1')
882
+ */
883
+ findByJuz(juz: JuzNumber, options?: GetVerseOptions): Promise<Verse[]>;
884
+ /**
885
+ * Get verses by hizb number.
886
+ * @param {HizbNumber} hizb hizb number
887
+ * @param {GetVerseOptions} options
888
+ * @example
889
+ * client.verses.findByHizb('1')
890
+ */
891
+ findByHizb(hizb: HizbNumber, options?: GetVerseOptions): Promise<Verse[]>;
892
+ /**
893
+ * Get verses by rub number.
894
+ * @param {RubNumber} rub rub number
895
+ * @param {GetVerseOptions} options
896
+ * @example
897
+ * client.verses.findByRub('1')
898
+ */
899
+ findByRub(rub: RubNumber, options?: GetVerseOptions): Promise<Verse[]>;
900
+ /**
901
+ * Get a random verse.
902
+ * @param {GetVerseOptions} options
903
+ * @example
904
+ * client.verses.findRandom()
905
+ */
906
+ findRandom(options?: GetVerseOptions): Promise<Verse>;
907
+ }
908
+
909
+ /**
910
+ * Main Quran API client
911
+ */
912
+ declare class QuranClient {
913
+ private config;
914
+ private fetcher;
915
+ readonly chapters: QuranChapters;
916
+ readonly verses: QuranVerses;
917
+ readonly juzs: QuranJuzs;
918
+ readonly audio: QuranAudio;
919
+ readonly resources: QuranResources;
920
+ readonly search: QuranSearch;
921
+ constructor(config: QuranClientConfig);
922
+ /**
923
+ * Get the current configuration
924
+ */
925
+ getConfig(): QuranClientConfig;
926
+ /**
927
+ * Update the configuration
928
+ */
929
+ updateConfig(newConfig: Partial<QuranClientConfig>): void;
930
+ /**
931
+ * Clear cached authentication token
932
+ */
933
+ clearCachedToken(): void;
934
+ }
935
+
936
+ /**
937
+ * Validates chapter id
938
+ * @param id chapter id
939
+ * @example
940
+ * isValidChapterId('1') // true
941
+ * isValidChapterId('114') // true
942
+ * isValidChapterId('0') // false
943
+ * isValidChapterId('-1') // false
944
+ * isValidChapterId('200') // false
945
+ */
946
+ declare const isValidChapterId: (id: string | number) => id is ChapterId;
947
+
948
+ /**
949
+ * Validates juz number
950
+ * @param juz juz number
951
+ * @example
952
+ * isValidJuz('1') // true
953
+ * isValidJuz('30') // true
954
+ * isValidJuz('0') // false
955
+ * isValidJuz('-1') // false
956
+ * isValidJuz('200') // false
957
+ */
958
+ declare const isValidJuz: (juz: string | number) => juz is JuzNumber;
959
+
960
+ /**
961
+ * Validates rub number
962
+ * @param rub rub number
963
+ * @example
964
+ * isValidRub('1') // true
965
+ * isValidRub('240') // true
966
+ * isValidRub('0') // false
967
+ * isValidRub('-1') // false
968
+ * isValidRub('300') // false
969
+ */
970
+ declare const isValidRub: (rub: string | number) => rub is RubNumber;
971
+
972
+ /**
973
+ * Validates hizb number
974
+ * @param hizb hizb number
975
+ * @example
976
+ * isValidHizb('1') // true
977
+ * isValidHizb('60') // true
978
+ * isValidHizb('0') // false
979
+ * isValidHizb('-1') // false
980
+ * isValidHizb('200') // false
981
+ */
982
+ declare const isValidHizb: (hizb: string | number) => hizb is HizbNumber;
983
+
984
+ /**
985
+ * Validates mushaf page number
986
+ * @param page mushaf page number
987
+ * @example
988
+ * isValidQuranPage('1') // true
989
+ * isValidQuranPage('604') // true
990
+ * isValidQuranPage('0') // false
991
+ * isValidQuranPage('-1') // false
992
+ * isValidQuranPage('1000') // false
993
+ */
994
+ declare const isValidQuranPage: (page: string | number) => page is PageNumber;
995
+
996
+ /**
997
+ * Validates verse key
998
+ * @param key colon separated verse key (chapter:verse)
999
+ * @example
1000
+ * isValidVerseKey('1:1') // true
1001
+ * isValidVerseKey('30:1') // true
1002
+ * isValidVerseKey('0') // false
1003
+ * isValidVerseKey('1:-') // false
1004
+ * isValidVerseKey('1_1') // false
1005
+ */
1006
+ declare const isValidVerseKey: (key: string) => key is VerseKey;
1007
+
1008
+ export { type ApiParams, type AudioResponse, type BaseApiParams, type CachedToken, type Chapter, type ChapterId, type ChapterInfo, type ChapterInfoResource, type ChapterRecitation, type ChapterReciterResource, CharType, type CustomFetcher, type Footnote, type HizbNumber, type Juz, type JuzNumber, Language, type LanguageResource, type PageNumber, type Pagination, type PaginationParams, QuranClient, type QuranClientConfig, QuranFont, type RecitationInfoResource, type RecitationResource, type RecitationStylesResource, type Reciter, type RubNumber, type SearchParams, type SearchResponse, type SearchResult, type Segment, type Tafsir, type TafsirInfo, type TafsirInfoResource, type TafsirResource, type TokenResponse, type TranslatedName, type Translation, type TranslationField, type TranslationInfoResource, type TranslationResource, type Transliteration, type Verse, type VerseField, type VerseKey, type VerseMediaResource, type VerseRecitation, type VerseRecitationField, type Word, type WordField, isValidChapterId, isValidHizb, isValidJuz, isValidQuranPage, isValidRub, isValidVerseKey };