GithubHelp home page GithubHelp logo

a7med3bdulbaset / hadith-api Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 1.0 36 KB

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/A7med3bdulBaset/hadith-json

JavaScript 3.53% TypeScript 96.47%
express mongodb muslim muslim-api nodejs

hadith-api's Introduction

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

hadith-api's People

Contributors

a7med3bdulbaset avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

merndev0603

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.