zubair-ali-zai-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

wakatime E2E Node.js CI GitHub License GitHub Release codecov Size typescript npm npm GitHub issues GitHub stars

zubair-ali-zai-sdk

SDK to access alathar.net content.

Installation

To install zubair-ali-zai-sdk, use npm or yarn:

npm install zubair-ali-zai-sdk
# or
yarn add zubair-ali-zai-sdk
# or
pnpm i zubair-ali-zai-sdk

Usage

Importing the SDK

import { init } from 'zubair-ali-zai-sdk';

Initialize the SDK

There are two ways to initialize the SDK to process the requests. Either set the environment variable directly:

ZUBAIR_ALI_ZAI_API="https://domain.com/:book/:id"

or use the init function:

import { init } from 'zubair-ali-zai-sdk';

init('https://domain.com/:book/:id');

Note that your URL pattern for the endpoint must have the :book and :id placeholders in it so that the correct book ID and hadith number can be substituted.

Get hadith

Retrieve metadata about a specific hadith.

(async () => {
    try {
        let hadith = await getAbuDawud(123); // from Sunan Abu Dawud
        hadith = await getIbnMajah(123); // from Sunan Ibn Majah
        hadith = await getMishkaat(123); //
        hadith = await getNasai(123);
        hadith = await getTirmidhi(123);
        console.log(hadith); // { arabic: 'حَدَّثَنَا مَحْمُودُ بْنُ خَالِدٍ', description: 'إسنادہ ضعیف باب ما جاء فی الرجل', hukm: 'حسن' }
    } catch (error) {
        console.error(error.message);
    }
})();

Package Sidebar

Install

npm i zubair-ali-zai-sdk

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

9.78 kB

Total Files

4

Last publish

Collaborators

  • ragaeeb