1.0.1 • Published 10 months ago

zubair-ali-zai-sdk v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

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);
    }
})();
1.0.1

10 months ago

1.0.0

10 months ago