Home

Awesome

ngx-hadeethenc-api

angular npm github Build Status prettier eslint jasmine MIT PRs

An Angular api client for Hadeeth Encyclopedia

HadeethEnc is a project aims to provide simplified explanations and clear translation of the authentic Prophetic (Prophet Muhammad ﷺ) hadiths.

Contents of the project can be used, with the following terms and conditions:

  1. No modification, addition, or deletion of the content.
  2. Clearly referring to the publisher and the source (HadeethEnc.com).

Features

Table of Contents

<!-- TOC start (generated with https://github.com/derlin/bitdowntoc) --> <!-- TOC end -->

Installation

NPM

npm install @wursha/ngx-hadeethenc-api

Yarn

yarn add @wursha/ngx-hadeethenc-api

PNPM

pnpm add @wursha/ngx-hadeethenc-api

Bun

bun add @wursha/ngx-hadeethenc-api

Getting Started:

first Inject the service NgxHadeethencApiService anywhere you want to use it

import { NgxHadeethencApiService } from "ngx-hadeethenc-api";

export class AppComponent {
    constructor(public service: NgxHadeethencApiService) {}
}

and make sure that HttpClient is provided

import { provideHttpClient } from "@angular/common/http";

export const appConfig: ApplicationConfig = {
    providers: [... , provideHttpClient()],
};

now you are ready to use it.

Available API endpoints:

List all available languages for HadeethEnc.com

getLanguages(): Observable<languageResponse[]>

This endpoint returns json object containing all available languages with their iso codes and native names.

List all categories by language code.

getCategoriesList(language: string): Observable<categoriesRespone[]>

This endpoint accepts language iso code and returns array of json objects each object represents a category.

List root categories by language code.

getCategoriesRoots(language: string): Observable<categoriesResponse[]>g

This endpoint returns root categories (main categories) in specific language, it accepts language iso code and returns json array of objects each object represents a root category.

List Hadeeths by category id and language iso code.

getHadeethsList(p: {
  language: string;
  categoryId: string;
  page: string;
  perPage: string;
}): Observable<hadeethsListResponse>

This endpoint accepts language iso code, category id (both required) and page (represents page number, optional defaults to 1) and per_page (optional defaults to 20) and returns json object containing "data" object which contains array of json objects each object represents a Hadeeth basic information (id, title, translations iso codes), the second object is "meta" containing meta data required for pagination.

Get single Hadeeth details by Hadeeth id and language iso code.

getHadeethsOne(p: {
    language: string;
    id: string;
}): Observable<hadeethsOneResponse>

The response differs when the language is "Arabic" or not, if it's Arabic then it returns all Hadeeth data (id, title, Hadeeth text (matn), explanation, hints (fawaed), word meaning and references), if non Arabic it returns translated parts (id, title, Hadeeth text (matn), explanation and hints (if translated), it doesnt return reference nor word meaning as they are not translated.

Response models:

hadeethsOneResponse

interface hadeethsOneResponse {
    id: string;
    title: string;
    hadeeth: string;
    attribution: string;
    grade: string;
    explanation: string;
    hints: string[];
    categories: string[];
    translations: string[];
    words_meanings: wordsMeaning[];
    reference: string;
    hadeeth_ar: string;
    explanation_ar: string;
    hints_ar: string[];
    words_meanings_ar: wordsMeaning[];
    attribution_ar: string;
    grade_ar: string;
}

interface wordsMeaning {
    word: string;
    meaning: string;
}

languageResponse

interface languageResponse {
    code: string;
    native: string;
}

categoriesResponse

interface categoriesResponse {
    id: string;
    title: string;
    hadeeths_count: string;
    parent_id?: string;
}

hadeethsListResponse

interface hadeethsListResponse {
    data: hadeethsListData[];
    meta: hadeethsListMeta;
}

interface hadeethsListData {
    id: string;
    title: string;
    translations: string[];
}

interface hadeethsListMeta {
    current_page: string;
    last_page: number;
    total_items: number;
    per_page: string;
}

Contributing

Feel free to submit a pull request for bugs or additions, and make sure to update tests as appropriate. If you find a mistake in the docs, send a PR! Even the smallest changes help.

For major changes, open an issue first to discuss what you'd like to change.

⭐ Found It Helpful? Star It!

If you found this project helpful, let the community know by giving it a star: 👉⭐

Core Team

<table> <tr> <td align="center"><a href="https://github.com/MuhAssar"><img src="https://avatars.githubusercontent.com/u/2022065?v=4" width="100px;" alt="Muhammad Assar"/><br /><sub><b>Muhammad Assar</b></sub></a></td> </tr> </table>

Other libs from the author

If you enjoy working with TypeScript, we also recommend other libraries by the same author: