Skip to content

Hadith-API is a RESTful API that let you access the hadiths from 17+ sunnah books, including the nine books. The data is from https://github.com/AhmedBaset/hadith-json

Notifications You must be signed in to change notification settings

AhmedBaset/hadith-api

Repository files navigation

Hadith-API

Hadith-API is a RESTful API that provides a simple way to access the hadiths from 17 books of hadiths, including the nine books and others. From hadith-json That was scraped here.

The API written in Node.js using Express.js framework and MongoDB for the database.

API Endpoints

Method Endpoint Description Example
GET /docs Get all the endpoints of the API. /docs
GET /books Get all the books in the database. /books
GET /book/:id Get a book with the specified id. /book/1
GET /book/:id/chapters Get all the chapters of the book with the specified id. /book/1/chapters
GET /chapters Get all the chapters in the database. /chapters
GET /chapter/:id Get a chapter with the specified id. /chapter/1
GET /hadith/:id Get a hadith with the specified id. /hadith/1
GET /book/:bookId/hadith/:id Get a hadith with the specified book id and hadith id /book/1/hadith/1

Before you start

Previously, We scraped the hadiths from the website sunnah.com and stored them in a MongoDB database. You can find the database in the hadith-json repository.

Installation

  1. Clone the repository.
git clone https://github.com/a7med3bdulbaset/hadith-api.git
  1. Install the dependencies.
# NPM
npm install
# Yarn
yarn install
  1. Setup the .env file as the .env.example file.
# The port that the server will run on.
PORT=3500 # Change it if conflict with another port.

# The MongoDB connection string. 
MONGODB_URI=mongodb+srv://<USERNAME>:<PASSWORD>@<DATABASE>.mongodb.net/?retryWrites=true&w=majority

To get the MONGODB_URI, You need to store the database from the hadith-json repository in MongoDB Atlas. Then, get the connection string from the Atlas dashboard.

  1. Compile the TypeScript code.
# NPM
npm run build
# Yarn
yarn build
  1. Start the server.
# NPM
npm start
# Yarn
yarn start

This will run the server on http://localhost:3500. You can change the port in the .env file.

  1. Dev server.
# NPM
npm run dev
# Yarn
yarn dev

About

Hadith-API is a RESTful API that let you access the hadiths from 17+ sunnah books, including the nine books. The data is from https://github.com/AhmedBaset/hadith-json

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy