Skip to main content

Complete Sahih al-Bukhari โ€” 7,277 hadiths with full Arabic text and English translations. Data loaded from CDN. CLI + Python library.

Project description

๐Ÿ•Œ Sahih al-Bukhari

One repo ยท one dataset ยท two packages โ€” npm and PyPI

npm version PyPI version License

๐Ÿ“š Complete Sahih al-Bukhari โ€” 7,277 hadiths, full Arabic + English.
Tiny installs, data from CDN. CLI + Node.js + React/Vue + Python.


๐Ÿ“‚ Monorepo Structure

sahih-al-bukhari/
โ”‚
โ”œโ”€โ”€ bin/
โ”‚   โ”œโ”€โ”€ bukhari.json        โ† ๐Ÿ”‘ SHARED โ€” single source of truth for JS + Python
โ”‚   โ””โ”€โ”€ index.js            โ† JS CLI entry
โ”‚
โ”œโ”€โ”€ chapters/               โ† ๐Ÿ”‘ SHARED โ€” generated by `node build.mjs`
โ”‚   โ”œโ”€โ”€ meta.json           โ”‚   used by CDN loader (JS browser) and Python CDN fallback
โ”‚   โ”œโ”€โ”€ 1.json              โ”‚
โ”‚   โ””โ”€โ”€ ...                 โ”‚
โ”‚
โ”œโ”€โ”€ sahih_al_bukhari/       โ† Python package
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ bukhari.py          โ† reads bin/bukhari.json automatically
โ”‚   โ””โ”€โ”€ cli.py
โ”‚
โ”œโ”€โ”€ index.js                โ† JS ESM (browser-safe, class only)
โ”œโ”€โ”€ index.cjs               โ† JS CommonJS (Node, reads bin/bukhari.json)
โ”œโ”€โ”€ index.node.js           โ† JS Node ESM (reads bin/bukhari.json)
โ”œโ”€โ”€ index.browser.js        โ† JS browser (CDN, auto-generated)
โ”œโ”€โ”€ index.d.ts              โ† TypeScript definitions
โ”œโ”€โ”€ build.mjs               โ† generates chapters/ from bin/bukhari.json
โ”‚
โ”œโ”€โ”€ package.json            โ† npm config
โ”œโ”€โ”€ pyproject.toml          โ† Python/Poetry config
โ”œโ”€โ”€ MANIFEST.in             โ† Python sdist: include data, exclude JS files
โ”œโ”€โ”€ .npmignore              โ† npm publish: exclude Python files
โ””โ”€โ”€ .gitignore

๐Ÿ”‘ Shared Data Files

File Used by
bin/bukhari.json JS (Node CJS/ESM CLI) + Python (auto-detected)
chapters/ JS browser (CDN fetch) + Python CDN fallback

You never need to duplicate or convert data. Both packages read the same file.


๐Ÿš€ Installation

# JavaScript / Node.js
npm install sahih-al-bukhari

# Python
pip install sahih-al-bukhari

๐ŸŸจ JavaScript Usage

// CommonJS
const bukhari = require('sahih-al-bukhari');

// ESM (Node)
import bukhari from 'sahih-al-bukhari';

bukhari.get(1)
bukhari.getByChapter(1)
bukhari.search('prayer')
bukhari.getRandom()
bukhari[0]
bukhari.length
bukhari.metadata
bukhari.chapters

React Hook

cd my-react-app
bukhari --react   # generates src/hooks/useBukhari.js
import { useBukhari } from '../hooks/useBukhari';

function HadithOfTheDay() {
  const bukhari = useBukhari();
  if (!bukhari) return <p>Loading...</p>;
  const h = bukhari.getRandom();
  return <p>{h.english.narrator}: {h.english.text}</p>;
}

๐Ÿ Python Usage

API is identical to the npm package (same camelCase method names):

from sahih_al_bukhari import Bukhari

bukhari = Bukhari()   # auto-reads bin/bukhari.json if in monorepo, else CDN

bukhari.get(1)
bukhari.getByChapter(1)
bukhari.search("prayer")
bukhari.search("prayer", limit=5)
bukhari.getRandom()
bukhari[0]
bukhari.length
bukhari.metadata
bukhari.chapters

# Array-style methods
bukhari.find(lambda h: h.id == 23)
bukhari.filter(lambda h: h.chapterId == 1)
bukhari.map(lambda h: h.narrator)
bukhari.slice(0, 10)

Custom path

bukhari = Bukhari(data_path="/absolute/path/to/bukhari.json")

๐Ÿ–ฅ๏ธ CLI (works from both npm and pip)

bukhari 1
bukhari 2345 -a          # Arabic only
bukhari 2345 -b          # Arabic + English
bukhari --search "prayer"
bukhari --search "fasting" --all
bukhari --chapter 5
bukhari --random
bukhari --react          # (JS only) generates React hook

๐Ÿ”ง Development

git clone https://github.com/SENODROOM/sahih-al-bukhari.git
cd sahih-al-bukhari
npm install

# Regenerate chapters/ from bin/bukhari.json
node build.mjs

# Publish JS
npm publish

# Publish Python
pip install build twine
python -m build
python -m twine upload dist/*

๐Ÿ“„ License

GNU Affero General Public License v3.0 (AGPL-3.0)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sahih_al_bukhari-3.1.1.tar.gz (6.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sahih_al_bukhari-3.1.1-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file sahih_al_bukhari-3.1.1.tar.gz.

File metadata

  • Download URL: sahih_al_bukhari-3.1.1.tar.gz
  • Upload date:
  • Size: 6.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.14.3

File hashes

Hashes for sahih_al_bukhari-3.1.1.tar.gz
Algorithm Hash digest
SHA256 08d97befd70962d06e0e72eeaf0bceee7ab39c6dab86de23dda139bfe2d35d33
MD5 dbac1fc83ff4304d0759021ba38a407c
BLAKE2b-256 6c3a25ab2b46d4a3177b40e064c074726c76c74dd55503d46e4f21970dfc5c69

See more details on using hashes here.

File details

Details for the file sahih_al_bukhari-3.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for sahih_al_bukhari-3.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 26f676fdebc82d77da1bbf28de09437dab30d01654de3ce4fbd9a4f0dd1a80aa
MD5 07e807ca5077cc4ab6df2d135850c3f7
BLAKE2b-256 7855bb8c68e5e65af06694464516c373595b26146d53d819ea223258439f776d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page