@wursha/ngx-hadeethenc-api
v0.0.4
Published
an Angular api client for hadeethenc.com
Downloads
97
Maintainers
Readme
ngx-hadeethenc-api
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:
- No modification, addition, or deletion of the content.
- Clearly referring to the publisher and the source (HadeethEnc.com).
Features
- ✅ Covers all HadeethEnc APIs.
- ✅ Using observable for all requests
- ✅ MIT Licensed
- ✅ Strongly typed using TypeScript
- ✅ Supports standalone Angular.
Table of Contents
- ngx-hadeethenc-api
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;
}
Core Team
Other libs from the author
If you enjoy working with TypeScript, we also recommend other libraries by the same author:
- ngx-prayertimes-api - 🕋 🚀 An Angular api client for Prayer Times API
- @wursha/ngx-prayertimes-api - npm package with built-in type declarations