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).
- β Covers all HadeethEnc APIs.
- β Using observable for all requests
- β MIT Licensed
- β Strongly typed using TypeScript
- β Supports standalone Angular.
- ngx-hadeethenc-api
npm install @wursha/ngx-hadeethenc-api
yarn add @wursha/ngx-hadeethenc-api
pnpm add @wursha/ngx-hadeethenc-api
bun add @wursha/ngx-hadeethenc-api
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.
getLanguages(): Observable<languageResponse[]>
This endpoint returns json object containing all available languages with their iso codes and native names.
getCategoriesList(language: string): Observable<categoriesRespone[]>
This endpoint accepts language iso code and returns array of json objects each object represents a category.
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.
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.
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.
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;
}
interface languageResponse {
code: string;
native: string;
}
interface categoriesResponse {
id: string;
title: string;
hadeeths_count: string;
parent_id?: string;
}
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;
}
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: πβ
Muhammad Assar |
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
- github-project-exporter - A tool to export GitHub Projects to JSON or CSV file format