hebcal-api 0.1.0__tar.gz
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.
- hebcal_api-0.1.0/LICENSE +7 -0
- hebcal_api-0.1.0/PKG-INFO +354 -0
- hebcal_api-0.1.0/README.md +339 -0
- hebcal_api-0.1.0/pyproject.toml +69 -0
- hebcal_api-0.1.0/setup.cfg +4 -0
- hebcal_api-0.1.0/src/hebcal_api/__init__.py +8 -0
- hebcal_api-0.1.0/src/hebcal_api/calendar.py +459 -0
- hebcal_api-0.1.0/src/hebcal_api/config.py +6 -0
- hebcal_api-0.1.0/src/hebcal_api/converter.py +243 -0
- hebcal_api-0.1.0/src/hebcal_api/leyning.py +175 -0
- hebcal_api-0.1.0/src/hebcal_api/shabat.py +221 -0
- hebcal_api-0.1.0/src/hebcal_api/tools/__init__.py +4 -0
- hebcal_api-0.1.0/src/hebcal_api/tools/exception.py +7 -0
- hebcal_api-0.1.0/src/hebcal_api/tools/logger.py +32 -0
- hebcal_api-0.1.0/src/hebcal_api/tools/types.py +561 -0
- hebcal_api-0.1.0/src/hebcal_api/tools/utils.py +65 -0
- hebcal_api-0.1.0/src/hebcal_api/yahrzeit.py +93 -0
- hebcal_api-0.1.0/src/hebcal_api/zmanim.py +173 -0
- hebcal_api-0.1.0/src/hebcal_api.egg-info/PKG-INFO +354 -0
- hebcal_api-0.1.0/src/hebcal_api.egg-info/SOURCES.txt +23 -0
- hebcal_api-0.1.0/src/hebcal_api.egg-info/dependency_links.txt +1 -0
- hebcal_api-0.1.0/src/hebcal_api.egg-info/requires.txt +2 -0
- hebcal_api-0.1.0/src/hebcal_api.egg-info/top_level.txt +1 -0
- hebcal_api-0.1.0/test/test_calender.py +5 -0
- hebcal_api-0.1.0/test/test_shabat.py +14 -0
hebcal_api-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2025 sudo-py-dev
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the βSoftwareβ), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED βAS ISβ, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hebcal-api
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Async client for Hebcal API
|
|
5
|
+
Author-email: sudo-py-dev <sudopydev@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/sudo-py-dev/hebcal-api
|
|
8
|
+
Project-URL: Issues, https://github.com/sudo-py-dev/hebcal-api/issues
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: httpx>=0.28.1
|
|
13
|
+
Requires-Dist: requests>=2.32.5
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# Hebcal API Client
|
|
17
|
+
|
|
18
|
+
[](https://badge.fury.io/py/hebcal-api)
|
|
19
|
+
[](https://www.python.org/downloads/)
|
|
20
|
+
[](https://github.com/sudo-py-dev/hebcal-api/blob/main/LICENSE)
|
|
21
|
+
|
|
22
|
+
A comprehensive, async-first Python client for the [Hebcal Jewish Calendar API](https://www.hebcal.com/home/195/jewish-calendar-rest-api). This library provides easy access to Jewish calendar events, Shabbat times, Torah readings, and more.
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
- ποΈ **Complete Calendar API** - Access all Jewish calendar events and holidays
|
|
27
|
+
- π―οΈ **Shabbat Times** - Get candle lighting and Havdalah times for any location
|
|
28
|
+
- π **Torah Readings** - Retrieve weekly Torah portions and leyning information
|
|
29
|
+
- β° **Zmanim** - Calculate daily Jewish prayer times and halachic times
|
|
30
|
+
- π **Date Conversion** - Convert between Hebrew and Gregorian dates
|
|
31
|
+
- π **Yahrzeit** - Calculate Hebrew death anniversaries
|
|
32
|
+
- β‘ **Async Support** - Full async/await support with httpx
|
|
33
|
+
- π **Sync Support** - Synchronous API with requests
|
|
34
|
+
- π **Location Support** - Geonames, coordinates, ZIP codes, and city names
|
|
35
|
+
- π **International** - Support for multiple languages and locations worldwide
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install hebcal-api
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Or install from source:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
git clone https://github.com/sudo-py-dev/hebcal-api.git
|
|
47
|
+
cd hebcal-api
|
|
48
|
+
pip install -e .
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Quick Start
|
|
52
|
+
|
|
53
|
+
### Basic Calendar Usage
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from hebcal_api import Calendar
|
|
57
|
+
|
|
58
|
+
# Create a calendar instance
|
|
59
|
+
calendar = Calendar()
|
|
60
|
+
|
|
61
|
+
# Get events for a specific date range
|
|
62
|
+
events = calendar.get_events(
|
|
63
|
+
start="2024-01-01",
|
|
64
|
+
end="2024-01-31",
|
|
65
|
+
geonameid=281184 # Jerusalem
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
for event in events.items:
|
|
69
|
+
print(f"{event.date}: {event.title}")
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Shabbat Times
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from hebcal_api import Shabat
|
|
76
|
+
|
|
77
|
+
# Create a Shabbat instance
|
|
78
|
+
shabat = Shabat()
|
|
79
|
+
|
|
80
|
+
# Get Shabbat times for New York
|
|
81
|
+
times = shabat.get_shabbat(
|
|
82
|
+
geonameid=5128581, # New York City
|
|
83
|
+
candle_lighting=True,
|
|
84
|
+
leyning=True # Include Torah reading
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
print(f"Candle lighting: {times.items[0].candle_lighting}")
|
|
88
|
+
print(f"Havdalah: {times.items[0].havdalah}")
|
|
89
|
+
print(f"Parasha: {times.items[0].parasha}")
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Async Usage
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
import asyncio
|
|
96
|
+
from hebcal_api import Calendar
|
|
97
|
+
|
|
98
|
+
async def main():
|
|
99
|
+
calendar = Calendar()
|
|
100
|
+
|
|
101
|
+
# Get events asynchronously
|
|
102
|
+
events = await calendar.get_events_async(
|
|
103
|
+
year=2024,
|
|
104
|
+
major_holidays=True,
|
|
105
|
+
geonameid=281184
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
for event in events.items:
|
|
109
|
+
print(f"{event.date}: {event.title}")
|
|
110
|
+
|
|
111
|
+
# Run the async function
|
|
112
|
+
asyncio.run(main())
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## API Reference
|
|
116
|
+
|
|
117
|
+
### Calendar Class
|
|
118
|
+
|
|
119
|
+
The main class for accessing Jewish calendar events and holidays.
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
from hebcal_api import Calendar
|
|
123
|
+
|
|
124
|
+
calendar = Calendar()
|
|
125
|
+
|
|
126
|
+
# Get events with various options
|
|
127
|
+
events = calendar.get_events(
|
|
128
|
+
# Date parameters
|
|
129
|
+
start="2024-01-01", # Start date (YYYY-MM-DD)
|
|
130
|
+
end="2024-12-31", # End date (YYYY-MM-DD)
|
|
131
|
+
year=2024, # Year (Gregorian or Hebrew)
|
|
132
|
+
month=1, # Month (1-12 or 'x' for all)
|
|
133
|
+
|
|
134
|
+
# Location (choose one)
|
|
135
|
+
geonameid=281184, # Geonames.org ID
|
|
136
|
+
zip_code="10001", # US ZIP code
|
|
137
|
+
latitude=40.7128, # Latitude
|
|
138
|
+
longitude=-74.0060, # Longitude
|
|
139
|
+
city_name="New York", # City name
|
|
140
|
+
|
|
141
|
+
# Event types
|
|
142
|
+
major_holidays=True, # Major Jewish holidays
|
|
143
|
+
minor_holidays=True, # Minor holidays
|
|
144
|
+
special_shabbatot=True, # Special Shabbatot
|
|
145
|
+
weekly_torah_portion=True, # Parashat Hashavua
|
|
146
|
+
candle_lighting_times=True, # Candle lighting
|
|
147
|
+
daf_yomi=True, # Daily Talmud study
|
|
148
|
+
|
|
149
|
+
# Other options
|
|
150
|
+
israel_holidays_and_torah_readings=True,
|
|
151
|
+
language="en" # Language code
|
|
152
|
+
)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Shabbat Class
|
|
156
|
+
|
|
157
|
+
Get Shabbat times and Torah readings for any location.
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
from hebcal_api import Shabat
|
|
161
|
+
|
|
162
|
+
shabat = Shabat()
|
|
163
|
+
|
|
164
|
+
times = shabat.get_shabbat(
|
|
165
|
+
# Location (required)
|
|
166
|
+
geonameid=5128581, # New York City
|
|
167
|
+
# latitude=40.7128, # Alternative: coordinates
|
|
168
|
+
# longitude=-74.0060,
|
|
169
|
+
|
|
170
|
+
# Times
|
|
171
|
+
candle_lighting=True, # Include candle lighting
|
|
172
|
+
havdalah_at_nightfall=True, # Use nightfall for Havdalah
|
|
173
|
+
|
|
174
|
+
# Torah portion
|
|
175
|
+
leyning=True, # Include weekly reading
|
|
176
|
+
|
|
177
|
+
# Timing adjustments
|
|
178
|
+
candle_lighting_minutes_before_sunset=18,
|
|
179
|
+
havdalah_minutes_after_sunset=42,
|
|
180
|
+
|
|
181
|
+
# Language
|
|
182
|
+
language="en"
|
|
183
|
+
)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Zmanim Class
|
|
187
|
+
|
|
188
|
+
Calculate daily Jewish prayer times and halachic times.
|
|
189
|
+
|
|
190
|
+
```python
|
|
191
|
+
from hebcal_api import Zmanim
|
|
192
|
+
|
|
193
|
+
zmanim = Zmanim()
|
|
194
|
+
|
|
195
|
+
times = zmanim.get_zmanim(
|
|
196
|
+
date="2024-01-15",
|
|
197
|
+
geonameid=281184, # Jerusalem
|
|
198
|
+
# Or use coordinates:
|
|
199
|
+
# latitude=31.7683,
|
|
200
|
+
# longitude=35.2137,
|
|
201
|
+
# timezone_id="Asia/Jerusalem"
|
|
202
|
+
)
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Date Converter
|
|
206
|
+
|
|
207
|
+
Convert between Hebrew and Gregorian dates.
|
|
208
|
+
|
|
209
|
+
```python
|
|
210
|
+
from hebcal_api import Converter
|
|
211
|
+
|
|
212
|
+
# Hebrew to Gregorian
|
|
213
|
+
gregorian = Converter.hdate_to_gdate(5784, 1, 15) # 15 Shevat 5784
|
|
214
|
+
print(f"Hebrew date 15/1/5784 = {gregorian}")
|
|
215
|
+
|
|
216
|
+
# Gregorian to Hebrew
|
|
217
|
+
hebrew = Converter.gdate_to_hdate(2024, 1, 15) # January 15, 2024
|
|
218
|
+
print(f"Gregorian date 2024-01-15 = {hebrew}")
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Yahrzeit
|
|
222
|
+
|
|
223
|
+
Calculate Hebrew death anniversaries.
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
from hebcal_api import Yahrzeit
|
|
227
|
+
|
|
228
|
+
yahrzeit = Yahrzeit()
|
|
229
|
+
|
|
230
|
+
# Calculate Yahrzeit for a death date
|
|
231
|
+
anniversaries = yahrzeit.get_yahrzeit(
|
|
232
|
+
death_date="2020-01-15", # Gregorian death date
|
|
233
|
+
year=2024, # Year to calculate for
|
|
234
|
+
geonameid=5128581 # Location for Hebrew date
|
|
235
|
+
)
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Advanced Usage
|
|
239
|
+
|
|
240
|
+
### Custom Parameters
|
|
241
|
+
|
|
242
|
+
All methods accept additional parameters supported by the Hebcal API:
|
|
243
|
+
|
|
244
|
+
```python
|
|
245
|
+
from hebcal_api import Calendar
|
|
246
|
+
|
|
247
|
+
calendar = Calendar()
|
|
248
|
+
|
|
249
|
+
# Pass any Hebcal API parameter
|
|
250
|
+
events = calendar.get_events(
|
|
251
|
+
year=2024,
|
|
252
|
+
major_holidays=True,
|
|
253
|
+
geonameid=281184,
|
|
254
|
+
extra_params={
|
|
255
|
+
"maj": "on", # Major holidays
|
|
256
|
+
"min": "on", # Minor holidays
|
|
257
|
+
"mod": "on", # Modern holidays
|
|
258
|
+
"i": "on", # Israel-specific holidays
|
|
259
|
+
"lg": "h" # Hebrew language
|
|
260
|
+
}
|
|
261
|
+
)
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Error Handling
|
|
265
|
+
|
|
266
|
+
```python
|
|
267
|
+
from hebcal_api import Calendar
|
|
268
|
+
from hebcal_api.tools.exception import FetchError
|
|
269
|
+
|
|
270
|
+
calendar = Calendar()
|
|
271
|
+
|
|
272
|
+
try:
|
|
273
|
+
events = calendar.get_events(year=2024, geonameid=281184)
|
|
274
|
+
print(f"Found {len(events.items)} events")
|
|
275
|
+
except FetchError as e:
|
|
276
|
+
print(f"API Error: {e}")
|
|
277
|
+
except ValueError as e:
|
|
278
|
+
print(f"Validation Error: {e}")
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## Development
|
|
282
|
+
|
|
283
|
+
### Setup Development Environment
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
git clone https://github.com/sudo-py-dev/hebcal-api.git
|
|
287
|
+
cd hebcal-api
|
|
288
|
+
python -m venv venv
|
|
289
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
290
|
+
pip install -e ".[dev]"
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Code Quality
|
|
294
|
+
|
|
295
|
+
This project uses several tools to maintain code quality:
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
# Format code
|
|
299
|
+
black src/
|
|
300
|
+
isort src/
|
|
301
|
+
|
|
302
|
+
# Lint code
|
|
303
|
+
ruff check src/
|
|
304
|
+
|
|
305
|
+
# Type checking (if mypy is installed)
|
|
306
|
+
mypy src/
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### Running Tests
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
# Run the test suite
|
|
313
|
+
python -m pytest
|
|
314
|
+
|
|
315
|
+
# Run with coverage
|
|
316
|
+
python -m pytest --cov=hebcal_api
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
## Contributing
|
|
320
|
+
|
|
321
|
+
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
|
|
322
|
+
|
|
323
|
+
### Development Guidelines
|
|
324
|
+
|
|
325
|
+
1. Follow PEP 8 style guidelines
|
|
326
|
+
2. Add type hints for all public functions
|
|
327
|
+
3. Include docstrings for all public classes and methods
|
|
328
|
+
4. Add tests for new functionality
|
|
329
|
+
5. Update documentation as needed
|
|
330
|
+
|
|
331
|
+
## License
|
|
332
|
+
|
|
333
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
334
|
+
|
|
335
|
+
## API Documentation
|
|
336
|
+
|
|
337
|
+
This library is a wrapper around the [Hebcal Jewish Calendar REST API](https://www.hebcal.com/home/195/jewish-calendar-rest-api). For complete API documentation, visit the official Hebcal API documentation.
|
|
338
|
+
|
|
339
|
+
## Support
|
|
340
|
+
|
|
341
|
+
If you encounter any issues or have questions:
|
|
342
|
+
|
|
343
|
+
- π§ Email: sudopydev@gmail.com
|
|
344
|
+
- π [GitHub Issues](https://github.com/sudo-py-dev/hebcal-api/issues)
|
|
345
|
+
- π [API Documentation](https://www.hebcal.com/home/195/jewish-calendar-rest-api)
|
|
346
|
+
|
|
347
|
+
## Changelog
|
|
348
|
+
|
|
349
|
+
### Version 0.1.0
|
|
350
|
+
- Initial release
|
|
351
|
+
- Complete API coverage for all Hebcal endpoints
|
|
352
|
+
- Async and sync support
|
|
353
|
+
- Comprehensive type hints
|
|
354
|
+
- Full documentation and examples
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
# Hebcal API Client
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/hebcal-api)
|
|
4
|
+
[](https://www.python.org/downloads/)
|
|
5
|
+
[](https://github.com/sudo-py-dev/hebcal-api/blob/main/LICENSE)
|
|
6
|
+
|
|
7
|
+
A comprehensive, async-first Python client for the [Hebcal Jewish Calendar API](https://www.hebcal.com/home/195/jewish-calendar-rest-api). This library provides easy access to Jewish calendar events, Shabbat times, Torah readings, and more.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- ποΈ **Complete Calendar API** - Access all Jewish calendar events and holidays
|
|
12
|
+
- π―οΈ **Shabbat Times** - Get candle lighting and Havdalah times for any location
|
|
13
|
+
- π **Torah Readings** - Retrieve weekly Torah portions and leyning information
|
|
14
|
+
- β° **Zmanim** - Calculate daily Jewish prayer times and halachic times
|
|
15
|
+
- π **Date Conversion** - Convert between Hebrew and Gregorian dates
|
|
16
|
+
- π **Yahrzeit** - Calculate Hebrew death anniversaries
|
|
17
|
+
- β‘ **Async Support** - Full async/await support with httpx
|
|
18
|
+
- π **Sync Support** - Synchronous API with requests
|
|
19
|
+
- π **Location Support** - Geonames, coordinates, ZIP codes, and city names
|
|
20
|
+
- π **International** - Support for multiple languages and locations worldwide
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install hebcal-api
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Or install from source:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
git clone https://github.com/sudo-py-dev/hebcal-api.git
|
|
32
|
+
cd hebcal-api
|
|
33
|
+
pip install -e .
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
### Basic Calendar Usage
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from hebcal_api import Calendar
|
|
42
|
+
|
|
43
|
+
# Create a calendar instance
|
|
44
|
+
calendar = Calendar()
|
|
45
|
+
|
|
46
|
+
# Get events for a specific date range
|
|
47
|
+
events = calendar.get_events(
|
|
48
|
+
start="2024-01-01",
|
|
49
|
+
end="2024-01-31",
|
|
50
|
+
geonameid=281184 # Jerusalem
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
for event in events.items:
|
|
54
|
+
print(f"{event.date}: {event.title}")
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Shabbat Times
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from hebcal_api import Shabat
|
|
61
|
+
|
|
62
|
+
# Create a Shabbat instance
|
|
63
|
+
shabat = Shabat()
|
|
64
|
+
|
|
65
|
+
# Get Shabbat times for New York
|
|
66
|
+
times = shabat.get_shabbat(
|
|
67
|
+
geonameid=5128581, # New York City
|
|
68
|
+
candle_lighting=True,
|
|
69
|
+
leyning=True # Include Torah reading
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
print(f"Candle lighting: {times.items[0].candle_lighting}")
|
|
73
|
+
print(f"Havdalah: {times.items[0].havdalah}")
|
|
74
|
+
print(f"Parasha: {times.items[0].parasha}")
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Async Usage
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
import asyncio
|
|
81
|
+
from hebcal_api import Calendar
|
|
82
|
+
|
|
83
|
+
async def main():
|
|
84
|
+
calendar = Calendar()
|
|
85
|
+
|
|
86
|
+
# Get events asynchronously
|
|
87
|
+
events = await calendar.get_events_async(
|
|
88
|
+
year=2024,
|
|
89
|
+
major_holidays=True,
|
|
90
|
+
geonameid=281184
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
for event in events.items:
|
|
94
|
+
print(f"{event.date}: {event.title}")
|
|
95
|
+
|
|
96
|
+
# Run the async function
|
|
97
|
+
asyncio.run(main())
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## API Reference
|
|
101
|
+
|
|
102
|
+
### Calendar Class
|
|
103
|
+
|
|
104
|
+
The main class for accessing Jewish calendar events and holidays.
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from hebcal_api import Calendar
|
|
108
|
+
|
|
109
|
+
calendar = Calendar()
|
|
110
|
+
|
|
111
|
+
# Get events with various options
|
|
112
|
+
events = calendar.get_events(
|
|
113
|
+
# Date parameters
|
|
114
|
+
start="2024-01-01", # Start date (YYYY-MM-DD)
|
|
115
|
+
end="2024-12-31", # End date (YYYY-MM-DD)
|
|
116
|
+
year=2024, # Year (Gregorian or Hebrew)
|
|
117
|
+
month=1, # Month (1-12 or 'x' for all)
|
|
118
|
+
|
|
119
|
+
# Location (choose one)
|
|
120
|
+
geonameid=281184, # Geonames.org ID
|
|
121
|
+
zip_code="10001", # US ZIP code
|
|
122
|
+
latitude=40.7128, # Latitude
|
|
123
|
+
longitude=-74.0060, # Longitude
|
|
124
|
+
city_name="New York", # City name
|
|
125
|
+
|
|
126
|
+
# Event types
|
|
127
|
+
major_holidays=True, # Major Jewish holidays
|
|
128
|
+
minor_holidays=True, # Minor holidays
|
|
129
|
+
special_shabbatot=True, # Special Shabbatot
|
|
130
|
+
weekly_torah_portion=True, # Parashat Hashavua
|
|
131
|
+
candle_lighting_times=True, # Candle lighting
|
|
132
|
+
daf_yomi=True, # Daily Talmud study
|
|
133
|
+
|
|
134
|
+
# Other options
|
|
135
|
+
israel_holidays_and_torah_readings=True,
|
|
136
|
+
language="en" # Language code
|
|
137
|
+
)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Shabbat Class
|
|
141
|
+
|
|
142
|
+
Get Shabbat times and Torah readings for any location.
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
from hebcal_api import Shabat
|
|
146
|
+
|
|
147
|
+
shabat = Shabat()
|
|
148
|
+
|
|
149
|
+
times = shabat.get_shabbat(
|
|
150
|
+
# Location (required)
|
|
151
|
+
geonameid=5128581, # New York City
|
|
152
|
+
# latitude=40.7128, # Alternative: coordinates
|
|
153
|
+
# longitude=-74.0060,
|
|
154
|
+
|
|
155
|
+
# Times
|
|
156
|
+
candle_lighting=True, # Include candle lighting
|
|
157
|
+
havdalah_at_nightfall=True, # Use nightfall for Havdalah
|
|
158
|
+
|
|
159
|
+
# Torah portion
|
|
160
|
+
leyning=True, # Include weekly reading
|
|
161
|
+
|
|
162
|
+
# Timing adjustments
|
|
163
|
+
candle_lighting_minutes_before_sunset=18,
|
|
164
|
+
havdalah_minutes_after_sunset=42,
|
|
165
|
+
|
|
166
|
+
# Language
|
|
167
|
+
language="en"
|
|
168
|
+
)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Zmanim Class
|
|
172
|
+
|
|
173
|
+
Calculate daily Jewish prayer times and halachic times.
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
from hebcal_api import Zmanim
|
|
177
|
+
|
|
178
|
+
zmanim = Zmanim()
|
|
179
|
+
|
|
180
|
+
times = zmanim.get_zmanim(
|
|
181
|
+
date="2024-01-15",
|
|
182
|
+
geonameid=281184, # Jerusalem
|
|
183
|
+
# Or use coordinates:
|
|
184
|
+
# latitude=31.7683,
|
|
185
|
+
# longitude=35.2137,
|
|
186
|
+
# timezone_id="Asia/Jerusalem"
|
|
187
|
+
)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Date Converter
|
|
191
|
+
|
|
192
|
+
Convert between Hebrew and Gregorian dates.
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
from hebcal_api import Converter
|
|
196
|
+
|
|
197
|
+
# Hebrew to Gregorian
|
|
198
|
+
gregorian = Converter.hdate_to_gdate(5784, 1, 15) # 15 Shevat 5784
|
|
199
|
+
print(f"Hebrew date 15/1/5784 = {gregorian}")
|
|
200
|
+
|
|
201
|
+
# Gregorian to Hebrew
|
|
202
|
+
hebrew = Converter.gdate_to_hdate(2024, 1, 15) # January 15, 2024
|
|
203
|
+
print(f"Gregorian date 2024-01-15 = {hebrew}")
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Yahrzeit
|
|
207
|
+
|
|
208
|
+
Calculate Hebrew death anniversaries.
|
|
209
|
+
|
|
210
|
+
```python
|
|
211
|
+
from hebcal_api import Yahrzeit
|
|
212
|
+
|
|
213
|
+
yahrzeit = Yahrzeit()
|
|
214
|
+
|
|
215
|
+
# Calculate Yahrzeit for a death date
|
|
216
|
+
anniversaries = yahrzeit.get_yahrzeit(
|
|
217
|
+
death_date="2020-01-15", # Gregorian death date
|
|
218
|
+
year=2024, # Year to calculate for
|
|
219
|
+
geonameid=5128581 # Location for Hebrew date
|
|
220
|
+
)
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Advanced Usage
|
|
224
|
+
|
|
225
|
+
### Custom Parameters
|
|
226
|
+
|
|
227
|
+
All methods accept additional parameters supported by the Hebcal API:
|
|
228
|
+
|
|
229
|
+
```python
|
|
230
|
+
from hebcal_api import Calendar
|
|
231
|
+
|
|
232
|
+
calendar = Calendar()
|
|
233
|
+
|
|
234
|
+
# Pass any Hebcal API parameter
|
|
235
|
+
events = calendar.get_events(
|
|
236
|
+
year=2024,
|
|
237
|
+
major_holidays=True,
|
|
238
|
+
geonameid=281184,
|
|
239
|
+
extra_params={
|
|
240
|
+
"maj": "on", # Major holidays
|
|
241
|
+
"min": "on", # Minor holidays
|
|
242
|
+
"mod": "on", # Modern holidays
|
|
243
|
+
"i": "on", # Israel-specific holidays
|
|
244
|
+
"lg": "h" # Hebrew language
|
|
245
|
+
}
|
|
246
|
+
)
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Error Handling
|
|
250
|
+
|
|
251
|
+
```python
|
|
252
|
+
from hebcal_api import Calendar
|
|
253
|
+
from hebcal_api.tools.exception import FetchError
|
|
254
|
+
|
|
255
|
+
calendar = Calendar()
|
|
256
|
+
|
|
257
|
+
try:
|
|
258
|
+
events = calendar.get_events(year=2024, geonameid=281184)
|
|
259
|
+
print(f"Found {len(events.items)} events")
|
|
260
|
+
except FetchError as e:
|
|
261
|
+
print(f"API Error: {e}")
|
|
262
|
+
except ValueError as e:
|
|
263
|
+
print(f"Validation Error: {e}")
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## Development
|
|
267
|
+
|
|
268
|
+
### Setup Development Environment
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
git clone https://github.com/sudo-py-dev/hebcal-api.git
|
|
272
|
+
cd hebcal-api
|
|
273
|
+
python -m venv venv
|
|
274
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
275
|
+
pip install -e ".[dev]"
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Code Quality
|
|
279
|
+
|
|
280
|
+
This project uses several tools to maintain code quality:
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
# Format code
|
|
284
|
+
black src/
|
|
285
|
+
isort src/
|
|
286
|
+
|
|
287
|
+
# Lint code
|
|
288
|
+
ruff check src/
|
|
289
|
+
|
|
290
|
+
# Type checking (if mypy is installed)
|
|
291
|
+
mypy src/
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Running Tests
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
# Run the test suite
|
|
298
|
+
python -m pytest
|
|
299
|
+
|
|
300
|
+
# Run with coverage
|
|
301
|
+
python -m pytest --cov=hebcal_api
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
## Contributing
|
|
305
|
+
|
|
306
|
+
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
|
|
307
|
+
|
|
308
|
+
### Development Guidelines
|
|
309
|
+
|
|
310
|
+
1. Follow PEP 8 style guidelines
|
|
311
|
+
2. Add type hints for all public functions
|
|
312
|
+
3. Include docstrings for all public classes and methods
|
|
313
|
+
4. Add tests for new functionality
|
|
314
|
+
5. Update documentation as needed
|
|
315
|
+
|
|
316
|
+
## License
|
|
317
|
+
|
|
318
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
319
|
+
|
|
320
|
+
## API Documentation
|
|
321
|
+
|
|
322
|
+
This library is a wrapper around the [Hebcal Jewish Calendar REST API](https://www.hebcal.com/home/195/jewish-calendar-rest-api). For complete API documentation, visit the official Hebcal API documentation.
|
|
323
|
+
|
|
324
|
+
## Support
|
|
325
|
+
|
|
326
|
+
If you encounter any issues or have questions:
|
|
327
|
+
|
|
328
|
+
- π§ Email: sudopydev@gmail.com
|
|
329
|
+
- π [GitHub Issues](https://github.com/sudo-py-dev/hebcal-api/issues)
|
|
330
|
+
- π [API Documentation](https://www.hebcal.com/home/195/jewish-calendar-rest-api)
|
|
331
|
+
|
|
332
|
+
## Changelog
|
|
333
|
+
|
|
334
|
+
### Version 0.1.0
|
|
335
|
+
- Initial release
|
|
336
|
+
- Complete API coverage for all Hebcal endpoints
|
|
337
|
+
- Async and sync support
|
|
338
|
+
- Comprehensive type hints
|
|
339
|
+
- Full documentation and examples
|