widequran 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +258 -0
- data/lib/widequran/client.rb +277 -0
- data/lib/widequran/version.rb +5 -0
- data/lib/widequran.rb +4 -0
- metadata +54 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: ae08237e178eee1834cca2b65436ffdb4c316f6b7ac0a0b5f7b8ab7bee5ffd59
|
|
4
|
+
data.tar.gz: 4223d14cafaffc9ee6aaa5c850259cbfad1b1a6cfff1bb507833a95e33a27eff
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5426184bfe78dfa791d65cbe7568fa244bb592cd0aec5e31be7aa9dc55fcacb206b631a2bcf570473055bc8802d077054e73a6dcc0e0cfd67514bfdcef5c72b7
|
|
7
|
+
data.tar.gz: d8be5c7c879c3805e73b085dd0299e6b1f72882cd0d008aba1a1efc5fcd24b61bdb8049ad1eb775738c215e00790c59cac55441a1bd9e3ffcda4dacd6b0ba8d6
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 WideHoly
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# widequran
|
|
2
|
+
|
|
3
|
+
[](https://rubygems.org/gems/widequran)
|
|
4
|
+
[](https://www.ruby-lang.org/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://rubygems.org/gems/widequran)
|
|
7
|
+
|
|
8
|
+
Ruby client for the [WideQuran](https://widequran.com) API. Access all 114 surahs, 6,236 ayahs with multiple translations, hadith collections (Bukhari, Muslim, Abu Dawud), tafsir commentary (Ibn Kathir, Al-Jalalayn), juz and hizb divisions, Quranic figures, Islamic topics, and Arabic glossary terms. Zero runtime dependencies -- uses only Ruby stdlib (`net/http`, `json`, `uri`).
|
|
9
|
+
|
|
10
|
+
WideQuran is a comprehensive Quran encyclopedia providing structured scripture data with Arabic text, transliterations, and scholarly translations -- all accessible through a free REST API.
|
|
11
|
+
|
|
12
|
+
> **Explore the Quran at [widequran.com](https://widequran.com)** -- [Surahs](https://widequran.com/surahs/), [Hadith](https://widequran.com/hadith/), [Tafsir](https://widequran.com/tafsir/), [People](https://widequran.com/people/), [Glossary](https://widequran.com/glossary/)
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
15
|
+
|
|
16
|
+
- [Install](#install)
|
|
17
|
+
- [Quick Start](#quick-start)
|
|
18
|
+
- [What You Can Do](#what-you-can-do)
|
|
19
|
+
- [Browse Surahs](#browse-surahs)
|
|
20
|
+
- [Read Ayahs](#read-ayahs)
|
|
21
|
+
- [Search Scripture](#search-scripture)
|
|
22
|
+
- [Navigate Juz and Hizb](#navigate-juz-and-hizb)
|
|
23
|
+
- [Study Tafsir Commentary](#study-tafsir-commentary)
|
|
24
|
+
- [Explore Hadith Collections](#explore-hadith-collections)
|
|
25
|
+
- [Discover Quranic Figures](#discover-quranic-figures)
|
|
26
|
+
- [Browse Topics and Glossary](#browse-topics-and-glossary)
|
|
27
|
+
- [API Reference](#api-reference)
|
|
28
|
+
- [Learn More About the Quran](#learn-more-about-the-quran)
|
|
29
|
+
- [WideHoly Scripture Family](#wideholy-scripture-family)
|
|
30
|
+
- [Also Available](#also-available)
|
|
31
|
+
- [License](#license)
|
|
32
|
+
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
gem install widequran
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Or add to your Gemfile:
|
|
40
|
+
|
|
41
|
+
```ruby
|
|
42
|
+
gem "widequran"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
```ruby
|
|
48
|
+
require "widequran"
|
|
49
|
+
|
|
50
|
+
# Create a client (zero configuration needed)
|
|
51
|
+
client = WideQuran::Client.new
|
|
52
|
+
|
|
53
|
+
# List all 114 surahs of the Quran
|
|
54
|
+
surahs = client.list_surahs
|
|
55
|
+
puts surahs["results"].first["name"] # => "Al-Fatihah"
|
|
56
|
+
|
|
57
|
+
# Search ayahs for a keyword
|
|
58
|
+
results = client.search("mercy")
|
|
59
|
+
results["results"].each { |a| puts a["text"] }
|
|
60
|
+
|
|
61
|
+
# Filter surahs by revelation type
|
|
62
|
+
meccan = client.list_surahs(revelation_type: "meccan")
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## What You Can Do
|
|
66
|
+
|
|
67
|
+
### Browse Surahs
|
|
68
|
+
|
|
69
|
+
The Quran contains 114 surahs (chapters), classified as Meccan (revealed in Mecca, 86 surahs) or Medinan (revealed in Medina, 28 surahs). Each surah has a name in Arabic and English, verse count, and revelation context.
|
|
70
|
+
|
|
71
|
+
```ruby
|
|
72
|
+
# List all surahs
|
|
73
|
+
surahs = client.list_surahs
|
|
74
|
+
|
|
75
|
+
# Get details for Al-Fatihah (The Opening)
|
|
76
|
+
fatihah = client.get_surah("al-fatihah")
|
|
77
|
+
puts fatihah["name"] # => "Al-Fatihah"
|
|
78
|
+
puts fatihah["ayah_count"] # => 7
|
|
79
|
+
|
|
80
|
+
# Filter by revelation type
|
|
81
|
+
medinan = client.list_surahs(revelation_type: "medinan")
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Read Ayahs
|
|
85
|
+
|
|
86
|
+
WideQuran provides 6,236 ayahs (verses) with Arabic text and multiple scholarly translations. Each ayah includes surah context, verse number, and translation metadata.
|
|
87
|
+
|
|
88
|
+
```ruby
|
|
89
|
+
# List ayahs for a specific surah
|
|
90
|
+
ayahs = client.list_ayahs(surah: "al-fatihah")
|
|
91
|
+
|
|
92
|
+
# Get a specific ayah by ID
|
|
93
|
+
ayah = client.get_ayah(1)
|
|
94
|
+
puts ayah["text"]
|
|
95
|
+
|
|
96
|
+
# Filter by translation
|
|
97
|
+
ayahs = client.list_ayahs(surah: "al-baqarah", translation: "sahih")
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Search Scripture
|
|
101
|
+
|
|
102
|
+
Full-text search across all Quran ayahs with optional surah restriction.
|
|
103
|
+
|
|
104
|
+
```ruby
|
|
105
|
+
# Search across the entire Quran
|
|
106
|
+
results = client.search("mercy")
|
|
107
|
+
results["results"].each do |ayah|
|
|
108
|
+
puts "#{ayah["surah_name"]} #{ayah["ayah_number"]}: #{ayah["text"]}"
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Search within a specific surah
|
|
112
|
+
results = client.search("believers", surah: "al-baqarah")
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Navigate Juz and Hizb
|
|
116
|
+
|
|
117
|
+
The Quran is divided into 30 juz (parts) for structured reading, each further split into hizb (half-juz) markers -- a system used for completing the Quran in Ramadan.
|
|
118
|
+
|
|
119
|
+
```ruby
|
|
120
|
+
# List all 30 juz
|
|
121
|
+
juz_list = client.list_juz
|
|
122
|
+
|
|
123
|
+
# Get details for juz 1
|
|
124
|
+
juz = client.get_juz(1)
|
|
125
|
+
|
|
126
|
+
# List hizb markers
|
|
127
|
+
hizbs = client.list_hizbs
|
|
128
|
+
hizb = client.get_hizb(1)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Study Tafsir Commentary
|
|
132
|
+
|
|
133
|
+
Tafsir (exegesis) provides scholarly interpretation of Quranic verses. WideQuran includes major commentary collections like Ibn Kathir and Al-Jalalayn.
|
|
134
|
+
|
|
135
|
+
```ruby
|
|
136
|
+
# List available tafsir collections
|
|
137
|
+
tafsirs = client.list_tafsirs
|
|
138
|
+
|
|
139
|
+
# Get details for Ibn Kathir's tafsir
|
|
140
|
+
ibn_kathir = client.get_tafsir("ibn-kathir")
|
|
141
|
+
|
|
142
|
+
# List commentary entries for a surah
|
|
143
|
+
entries = client.list_tafsir_entries(tafsir: "ibn-kathir", surah: "al-fatihah")
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Explore Hadith Collections
|
|
147
|
+
|
|
148
|
+
Hadith are recorded sayings and actions of Prophet Muhammad. WideQuran provides access to the six canonical collections (Kutub al-Sittah) with authentication grades.
|
|
149
|
+
|
|
150
|
+
| Collection | Compiler | Hadiths |
|
|
151
|
+
|------------|----------|---------|
|
|
152
|
+
| Sahih al-Bukhari | Imam al-Bukhari | 7,275 |
|
|
153
|
+
| Sahih Muslim | Imam Muslim | 7,453 |
|
|
154
|
+
| Sunan Abu Dawud | Abu Dawud | 5,274 |
|
|
155
|
+
| Jami at-Tirmidhi | At-Tirmidhi | 3,956 |
|
|
156
|
+
| Sunan an-Nasai | An-Nasai | 5,758 |
|
|
157
|
+
| Sunan Ibn Majah | Ibn Majah | 4,341 |
|
|
158
|
+
|
|
159
|
+
```ruby
|
|
160
|
+
# List hadith collections
|
|
161
|
+
collections = client.list_hadith_collections
|
|
162
|
+
|
|
163
|
+
# List hadiths from Bukhari
|
|
164
|
+
hadiths = client.list_hadiths(collection: "bukhari")
|
|
165
|
+
|
|
166
|
+
# Search hadith texts
|
|
167
|
+
results = client.search_hadith("prayer", collection: "muslim")
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Discover Quranic Figures
|
|
171
|
+
|
|
172
|
+
Profiles of prophets and figures mentioned in the Quran, including Ibrahim, Musa, Isa, and Muhammad (peace be upon them all).
|
|
173
|
+
|
|
174
|
+
```ruby
|
|
175
|
+
# List all Quranic people
|
|
176
|
+
people = client.list_people
|
|
177
|
+
|
|
178
|
+
# Filter to prophets only
|
|
179
|
+
prophets = client.list_people(is_prophet: true)
|
|
180
|
+
|
|
181
|
+
# Get details for a specific person
|
|
182
|
+
ibrahim = client.get_person("ibrahim")
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Browse Topics and Glossary
|
|
186
|
+
|
|
187
|
+
Thematic collections of ayahs by topic (mercy, justice, patience) and an Arabic-English glossary of Islamic terms.
|
|
188
|
+
|
|
189
|
+
```ruby
|
|
190
|
+
# List topics
|
|
191
|
+
topics = client.list_topics
|
|
192
|
+
topic = client.get_topic("mercy")
|
|
193
|
+
|
|
194
|
+
# Browse glossary terms
|
|
195
|
+
terms = client.list_glossary
|
|
196
|
+
term = client.get_term("tawakkul")
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## API Reference
|
|
200
|
+
|
|
201
|
+
| Method | Description |
|
|
202
|
+
|--------|-------------|
|
|
203
|
+
| `list_surahs(revelation_type:)` | List all 114 surahs |
|
|
204
|
+
| `get_surah(slug)` | Get surah details |
|
|
205
|
+
| `list_translations(language:)` | List available translations |
|
|
206
|
+
| `get_translation(code)` | Get translation details |
|
|
207
|
+
| `list_ayahs(surah:, translation:)` | List ayahs with filters |
|
|
208
|
+
| `get_ayah(ayah_id)` | Get a specific ayah |
|
|
209
|
+
| `search(query, surah:)` | Search ayahs by keyword |
|
|
210
|
+
| `list_juz` | List all 30 juz |
|
|
211
|
+
| `get_juz(number)` | Get juz details |
|
|
212
|
+
| `list_hizbs(juz:)` | List hizb markers |
|
|
213
|
+
| `get_hizb(number)` | Get hizb details |
|
|
214
|
+
| `list_tafsirs` | List tafsir collections |
|
|
215
|
+
| `get_tafsir(slug)` | Get tafsir details |
|
|
216
|
+
| `list_tafsir_entries(tafsir:, surah:)` | List commentary entries |
|
|
217
|
+
| `get_tafsir_entry(entry_id)` | Get a tafsir entry |
|
|
218
|
+
| `list_hadith_collections` | List hadith collections |
|
|
219
|
+
| `get_hadith_collection(slug)` | Get collection details |
|
|
220
|
+
| `list_hadiths(collection:, grade:)` | List hadiths |
|
|
221
|
+
| `get_hadith(hadith_id)` | Get a specific hadith |
|
|
222
|
+
| `search_hadith(query, collection:)` | Search hadith texts |
|
|
223
|
+
| `list_people(is_prophet:)` | List Quranic figures |
|
|
224
|
+
| `get_person(slug)` | Get person details |
|
|
225
|
+
| `list_topics` | List Quranic topics |
|
|
226
|
+
| `get_topic(slug)` | Get topic details |
|
|
227
|
+
| `list_glossary` | List glossary terms |
|
|
228
|
+
| `get_term(slug)` | Get term definition |
|
|
229
|
+
|
|
230
|
+
## Learn More About the Quran
|
|
231
|
+
|
|
232
|
+
- **Browse**: [Surahs](https://widequran.com/surahs/) -- [Hadith Collections](https://widequran.com/hadith/) -- [People](https://widequran.com/people/)
|
|
233
|
+
- **Study**: [Tafsir](https://widequran.com/tafsir/) -- [Topics](https://widequran.com/topics/) -- [Glossary](https://widequran.com/glossary/)
|
|
234
|
+
- **API**: [REST API Docs](https://widequran.com/developers/) -- [OpenAPI Spec](https://widequran.com/api/openapi.json)
|
|
235
|
+
|
|
236
|
+
## WideHoly Scripture Family
|
|
237
|
+
|
|
238
|
+
Part of the [WideHoly](https://wideholy.com) multi-religion scripture platform.
|
|
239
|
+
|
|
240
|
+
| Site | Domain | Focus |
|
|
241
|
+
|------|--------|-------|
|
|
242
|
+
| WideBible | [widebible.com](https://widebible.com) | 66 books, 31,102 verses, KJV/ASV/BBE/YLT, cross-references |
|
|
243
|
+
| **WideQuran** | [widequran.com](https://widequran.com) | **114 surahs, 6,236 ayahs, hadith collections, tafsir** |
|
|
244
|
+
| WideTorah | [widetorah.com](https://widetorah.com) | Tanakh, Talmud tractates, parashot, Rashi commentary |
|
|
245
|
+
| WideGita | [widegita.com](https://widegita.com) | 18 chapters, 700 verses, Upanishads, Yoga Sutras |
|
|
246
|
+
| WideSutra | [widesutra.com](https://widesutra.com) | Tipitaka, Pali Canon, Mahayana sutras, Buddhist figures |
|
|
247
|
+
| WideHoly | [wideholy.com](https://wideholy.com) | Cross-religion search, verse comparison, shared topics |
|
|
248
|
+
|
|
249
|
+
## Also Available
|
|
250
|
+
|
|
251
|
+
| Platform | Install | Link |
|
|
252
|
+
|----------|---------|------|
|
|
253
|
+
| **PyPI** | `pip install widequran` | [PyPI](https://pypi.org/project/widequran/) |
|
|
254
|
+
| **npm** | `npm install widequran` | [npm](https://www.npmjs.com/package/widequran) |
|
|
255
|
+
|
|
256
|
+
## License
|
|
257
|
+
|
|
258
|
+
MIT
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "json"
|
|
5
|
+
require "uri"
|
|
6
|
+
|
|
7
|
+
module WideQuran
|
|
8
|
+
# HTTP client for the WideQuran REST API.
|
|
9
|
+
#
|
|
10
|
+
# Zero runtime dependencies -- uses only Ruby stdlib (net/http, json, uri).
|
|
11
|
+
#
|
|
12
|
+
# client = WideQuran::Client.new
|
|
13
|
+
# surahs = client.list_surahs
|
|
14
|
+
# ayahs = client.search("mercy")
|
|
15
|
+
#
|
|
16
|
+
class Client
|
|
17
|
+
DEFAULT_BASE_URL = "https://widequran.com/api/v1/quran"
|
|
18
|
+
DEFAULT_TIMEOUT = 10
|
|
19
|
+
|
|
20
|
+
def initialize(base_url: DEFAULT_BASE_URL, timeout: DEFAULT_TIMEOUT)
|
|
21
|
+
@base_url = base_url.chomp("/")
|
|
22
|
+
@timeout = timeout
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# --- Surahs ---------------------------------------------------------------
|
|
26
|
+
|
|
27
|
+
# List all 114 surahs of the Quran.
|
|
28
|
+
#
|
|
29
|
+
# @param revelation_type [String, nil] filter by "meccan" or "medinan"
|
|
30
|
+
# @return [Hash] paginated list of surahs
|
|
31
|
+
def list_surahs(revelation_type: nil, **params)
|
|
32
|
+
get("/surahs/", { revelation_type: revelation_type }.merge(params))
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Get surah details by slug (e.g. "al-fatihah").
|
|
36
|
+
#
|
|
37
|
+
# @param slug [String] surah URL slug
|
|
38
|
+
# @return [Hash] surah details
|
|
39
|
+
def get_surah(slug)
|
|
40
|
+
get("/surahs/#{slug}/")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# --- Translations ---------------------------------------------------------
|
|
44
|
+
|
|
45
|
+
# List available Quran translations.
|
|
46
|
+
#
|
|
47
|
+
# @param language [String, nil] filter by language code (e.g. "en", "ar")
|
|
48
|
+
# @return [Hash] paginated list of translations
|
|
49
|
+
def list_translations(language: nil, **params)
|
|
50
|
+
get("/translations/", { language: language }.merge(params))
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Get translation details by code (e.g. "sahih").
|
|
54
|
+
#
|
|
55
|
+
# @param code [String] translation code
|
|
56
|
+
# @return [Hash] translation details
|
|
57
|
+
def get_translation(code)
|
|
58
|
+
get("/translations/#{code}/")
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# --- Ayahs ----------------------------------------------------------------
|
|
62
|
+
|
|
63
|
+
# List ayahs with optional filters.
|
|
64
|
+
#
|
|
65
|
+
# @param surah [String, nil] filter by surah slug
|
|
66
|
+
# @param translation [String, nil] filter by translation code
|
|
67
|
+
# @return [Hash] paginated list of ayahs
|
|
68
|
+
def list_ayahs(surah: nil, translation: nil, **params)
|
|
69
|
+
get("/ayahs/", { surah: surah, translation: translation }.merge(params))
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Get a specific ayah by its ID.
|
|
73
|
+
#
|
|
74
|
+
# @param ayah_id [Integer] ayah ID
|
|
75
|
+
# @return [Hash] ayah details
|
|
76
|
+
def get_ayah(ayah_id)
|
|
77
|
+
get("/ayahs/#{ayah_id}/")
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Search ayahs by text content.
|
|
81
|
+
#
|
|
82
|
+
# @param query [String] search query string
|
|
83
|
+
# @param surah [String, nil] restrict search to a specific surah slug
|
|
84
|
+
# @return [Hash] paginated search results
|
|
85
|
+
def search(query, surah: nil)
|
|
86
|
+
get("/ayahs/", { search: query, surah: surah })
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# --- Juz & Hizb -----------------------------------------------------------
|
|
90
|
+
|
|
91
|
+
# List all 30 juz (parts) of the Quran.
|
|
92
|
+
#
|
|
93
|
+
# @return [Hash] paginated list of juz
|
|
94
|
+
def list_juz
|
|
95
|
+
get("/juz/")
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Get juz details by number (1-30).
|
|
99
|
+
#
|
|
100
|
+
# @param number [Integer] juz number
|
|
101
|
+
# @return [Hash] juz details
|
|
102
|
+
def get_juz(number)
|
|
103
|
+
get("/juz/#{number}/")
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# List hizb (half-juz) markers.
|
|
107
|
+
#
|
|
108
|
+
# @param juz [Integer, nil] filter by juz number
|
|
109
|
+
# @return [Hash] paginated list of hizbs
|
|
110
|
+
def list_hizbs(juz: nil, **params)
|
|
111
|
+
get("/hizbs/", { juz: juz }.merge(params))
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Get hizb details by number.
|
|
115
|
+
#
|
|
116
|
+
# @param number [Integer] hizb number
|
|
117
|
+
# @return [Hash] hizb details
|
|
118
|
+
def get_hizb(number)
|
|
119
|
+
get("/hizbs/#{number}/")
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# --- Tafsir ---------------------------------------------------------------
|
|
123
|
+
|
|
124
|
+
# List available tafsir (commentary) collections.
|
|
125
|
+
#
|
|
126
|
+
# @return [Hash] paginated list of tafsirs
|
|
127
|
+
def list_tafsirs
|
|
128
|
+
get("/tafsirs/")
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# Get tafsir details by slug (e.g. "ibn-kathir").
|
|
132
|
+
#
|
|
133
|
+
# @param slug [String] tafsir slug
|
|
134
|
+
# @return [Hash] tafsir details
|
|
135
|
+
def get_tafsir(slug)
|
|
136
|
+
get("/tafsirs/#{slug}/")
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# List tafsir entries with optional filters.
|
|
140
|
+
#
|
|
141
|
+
# @param tafsir [String, nil] filter by tafsir slug
|
|
142
|
+
# @param surah [String, nil] filter by surah slug
|
|
143
|
+
# @return [Hash] paginated list of tafsir entries
|
|
144
|
+
def list_tafsir_entries(tafsir: nil, surah: nil, **params)
|
|
145
|
+
get("/tafsir-entries/", { tafsir: tafsir, surah: surah }.merge(params))
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Get a specific tafsir entry by ID.
|
|
149
|
+
#
|
|
150
|
+
# @param entry_id [Integer] tafsir entry ID
|
|
151
|
+
# @return [Hash] tafsir entry details
|
|
152
|
+
def get_tafsir_entry(entry_id)
|
|
153
|
+
get("/tafsir-entries/#{entry_id}/")
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# --- Hadith ---------------------------------------------------------------
|
|
157
|
+
|
|
158
|
+
# List hadith collections (Bukhari, Muslim, etc.).
|
|
159
|
+
#
|
|
160
|
+
# @return [Hash] paginated list of hadith collections
|
|
161
|
+
def list_hadith_collections
|
|
162
|
+
get("/hadith-collections/")
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# Get hadith collection details by slug.
|
|
166
|
+
#
|
|
167
|
+
# @param slug [String] collection slug
|
|
168
|
+
# @return [Hash] collection details
|
|
169
|
+
def get_hadith_collection(slug)
|
|
170
|
+
get("/hadith-collections/#{slug}/")
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# List hadiths with optional filters.
|
|
174
|
+
#
|
|
175
|
+
# @param collection [String, nil] filter by collection slug
|
|
176
|
+
# @param grade [String, nil] filter by grade (e.g. "sahih")
|
|
177
|
+
# @return [Hash] paginated list of hadiths
|
|
178
|
+
def list_hadiths(collection: nil, grade: nil, **params)
|
|
179
|
+
get("/hadiths/", { collection: collection, grade: grade }.merge(params))
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# Get a specific hadith by ID.
|
|
183
|
+
#
|
|
184
|
+
# @param hadith_id [Integer] hadith ID
|
|
185
|
+
# @return [Hash] hadith details
|
|
186
|
+
def get_hadith(hadith_id)
|
|
187
|
+
get("/hadiths/#{hadith_id}/")
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Search hadith by text content.
|
|
191
|
+
#
|
|
192
|
+
# @param query [String] search query string
|
|
193
|
+
# @param collection [String, nil] restrict to a specific collection
|
|
194
|
+
# @return [Hash] paginated search results
|
|
195
|
+
def search_hadith(query, collection: nil)
|
|
196
|
+
get("/hadiths/", { search: query, collection: collection })
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# --- People ---------------------------------------------------------------
|
|
200
|
+
|
|
201
|
+
# List Quranic people (prophets and figures).
|
|
202
|
+
#
|
|
203
|
+
# @param is_prophet [Boolean, nil] filter to prophets only
|
|
204
|
+
# @return [Hash] paginated list of people
|
|
205
|
+
def list_people(is_prophet: nil, **params)
|
|
206
|
+
get("/people/", { is_prophet: is_prophet }.merge(params))
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Get Quranic person details by slug.
|
|
210
|
+
#
|
|
211
|
+
# @param slug [String] person slug
|
|
212
|
+
# @return [Hash] person details
|
|
213
|
+
def get_person(slug)
|
|
214
|
+
get("/people/#{slug}/")
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# --- Topics & Glossary ----------------------------------------------------
|
|
218
|
+
|
|
219
|
+
# List Quranic topics and themes.
|
|
220
|
+
#
|
|
221
|
+
# @return [Hash] paginated list of topics
|
|
222
|
+
def list_topics
|
|
223
|
+
get("/topics/")
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# Get topic details by slug.
|
|
227
|
+
#
|
|
228
|
+
# @param slug [String] topic slug
|
|
229
|
+
# @return [Hash] topic details
|
|
230
|
+
def get_topic(slug)
|
|
231
|
+
get("/topics/#{slug}/")
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
# List Islamic glossary terms.
|
|
235
|
+
#
|
|
236
|
+
# @return [Hash] paginated list of glossary terms
|
|
237
|
+
def list_glossary
|
|
238
|
+
get("/glossary/")
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
# Get glossary term details by slug.
|
|
242
|
+
#
|
|
243
|
+
# @param slug [String] term slug
|
|
244
|
+
# @return [Hash] term details
|
|
245
|
+
def get_term(slug)
|
|
246
|
+
get("/glossary/#{slug}/")
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
private
|
|
250
|
+
|
|
251
|
+
def get(path, params = {})
|
|
252
|
+
uri = URI("#{@base_url}#{path}")
|
|
253
|
+
cleaned = params.each_with_object({}) { |(k, v), h| h[k] = v unless v.nil? }
|
|
254
|
+
uri.query = URI.encode_www_form(cleaned) unless cleaned.empty?
|
|
255
|
+
|
|
256
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
257
|
+
http.use_ssl = uri.scheme == "https"
|
|
258
|
+
http.open_timeout = @timeout
|
|
259
|
+
http.read_timeout = @timeout
|
|
260
|
+
|
|
261
|
+
request = Net::HTTP::Get.new(uri)
|
|
262
|
+
request["Accept"] = "application/json"
|
|
263
|
+
request["User-Agent"] = "widequran-rb/#{VERSION}"
|
|
264
|
+
|
|
265
|
+
response = http.request(request)
|
|
266
|
+
|
|
267
|
+
case response
|
|
268
|
+
when Net::HTTPSuccess
|
|
269
|
+
JSON.parse(response.body)
|
|
270
|
+
when Net::HTTPNotFound
|
|
271
|
+
raise "Not found: #{path}"
|
|
272
|
+
else
|
|
273
|
+
raise "HTTP #{response.code}: #{response.body}"
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
end
|
data/lib/widequran.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: widequran
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- dobestan
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-03-24 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: API client for widequran.com. Access 114 surahs, 6,236 ayahs, hadith
|
|
14
|
+
collections (Bukhari, Muslim), tafsir commentary (Ibn Kathir), juz/hizb divisions,
|
|
15
|
+
Quranic people, topics, and glossary. Zero dependencies.
|
|
16
|
+
email:
|
|
17
|
+
executables: []
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- LICENSE
|
|
22
|
+
- README.md
|
|
23
|
+
- lib/widequran.rb
|
|
24
|
+
- lib/widequran/client.rb
|
|
25
|
+
- lib/widequran/version.rb
|
|
26
|
+
homepage: https://widequran.com
|
|
27
|
+
licenses:
|
|
28
|
+
- MIT
|
|
29
|
+
metadata:
|
|
30
|
+
homepage_uri: https://widequran.com
|
|
31
|
+
source_code_uri: https://github.com/dobestan/widequran-rb
|
|
32
|
+
changelog_uri: https://github.com/dobestan/widequran-rb/blob/main/CHANGELOG.md
|
|
33
|
+
documentation_uri: https://widequran.com/developers/
|
|
34
|
+
bug_tracker_uri: https://github.com/dobestan/widequran-rb/issues
|
|
35
|
+
post_install_message:
|
|
36
|
+
rdoc_options: []
|
|
37
|
+
require_paths:
|
|
38
|
+
- lib
|
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '3.0'
|
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - ">="
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '0'
|
|
49
|
+
requirements: []
|
|
50
|
+
rubygems_version: 3.0.3.1
|
|
51
|
+
signing_key:
|
|
52
|
+
specification_version: 4
|
|
53
|
+
summary: Ruby SDK for WideQuran — Quran surahs, ayahs, hadith, tafsir commentary
|
|
54
|
+
test_files: []
|