Python client for Diyanet prayer times API
Project description
pydiyanet
Python client library for the Diyanet prayer times API.
Features
- Async/await support using aiohttp
- Full type hints with py.typed for mypy compatibility
- Authentication and token refresh handling
- Access to prayer times, countries, states, and cities
- Comprehensive error handling
Installation
pip install pydiyanet
Usage
import asyncio
from aiohttp import ClientSession
from pydiyanet import DiyanetApiClient, DiyanetAuthError, DiyanetConnectionError
async def main():
async with ClientSession() as session:
client = DiyanetApiClient(session, "your-email@example.com", "your-password")
try:
# Authenticate
await client.authenticate()
# Get prayer times for a location
prayer_times = await client.get_prayer_times(location_id=9146)
print(f"Fajr: {prayer_times['fajr']}")
print(f"Dhuhr: {prayer_times['dhuhr']}")
# Get countries
countries = await client.get_countries()
# Get states for a country
states = await client.get_states(country_id=2)
# Get cities for a state
cities = await client.get_cities(state_id=9)
except DiyanetAuthError as err:
print(f"Authentication failed: {err}")
except DiyanetConnectionError as err:
print(f"Connection error: {err}")
asyncio.run(main())
API Reference
DiyanetApiClient
__init__(session: ClientSession, email: str, password: str)
Initialize the API client with an aiohttp session and credentials.
async authenticate() -> bool
Authenticate with the Diyanet API and obtain access/refresh tokens.
Raises:
DiyanetAuthError: If authentication failsDiyanetConnectionError: If there's a network error
async get_prayer_times(location_id: int) -> dict[str, Any]
Get prayer times for a specific location.
Returns a dictionary containing prayer times for the current day.
async get_countries() -> list[dict[str, Any]]
Get list of all available countries.
async get_states(country_id: int) -> list[dict[str, Any]]
Get list of states for a given country.
async get_cities(state_id: int) -> list[dict[str, Any]]
Get list of cities for a given state.
async get_city_detail(city_id: int) -> dict[str, Any] | None
Get detailed information for a specific city.
Exceptions
DiyanetApiError: Base exception for all API errorsDiyanetAuthError: Raised when authentication failsDiyanetConnectionError: Raised when there's a network/connection error
Token Management
The client automatically handles token expiration and refresh:
- Access tokens expire after 30 minutes
- Refresh tokens expire after 45 minutes
- Tokens are automatically refreshed when needed
- Full re-authentication occurs when refresh token expires
Requirements
- Python 3.11+
- aiohttp >= 3.9.0
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydiyanet-0.1.2.tar.gz.
File metadata
- Download URL: pydiyanet-0.1.2.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c173735c086fabdce66b57243ef2867e5e0fbd0f31a2bb6c1f47a9e5af09e3b
|
|
| MD5 |
7efd0eb9eb70b11e5084a55dbce0ffd7
|
|
| BLAKE2b-256 |
3d1aae5dec27f006905ad43fae6a6e2f6227d54c6dd8bd15661696317bd8fa7b
|
Provenance
The following attestation bundles were made for pydiyanet-0.1.2.tar.gz:
Publisher:
publish.yml on mahdemir/pydiyanet
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydiyanet-0.1.2.tar.gz -
Subject digest:
0c173735c086fabdce66b57243ef2867e5e0fbd0f31a2bb6c1f47a9e5af09e3b - Sigstore transparency entry: 1005366543
- Sigstore integration time:
-
Permalink:
mahdemir/pydiyanet@d211e29ee73c070a47189ac4e6d42a0ebd42782f -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/mahdemir
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d211e29ee73c070a47189ac4e6d42a0ebd42782f -
Trigger Event:
push
-
Statement type:
File details
Details for the file pydiyanet-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pydiyanet-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c2e0de4e3ff6df43b8767f55656188097140094287b77b634ab40a2be2efc35
|
|
| MD5 |
621b2a41101d376699fd5630a2ddcb84
|
|
| BLAKE2b-256 |
728eb8a3d5be291124ebe68e6d3fb755cdc6d6239e9af281427681e6257763b4
|
Provenance
The following attestation bundles were made for pydiyanet-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on mahdemir/pydiyanet
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydiyanet-0.1.2-py3-none-any.whl -
Subject digest:
2c2e0de4e3ff6df43b8767f55656188097140094287b77b634ab40a2be2efc35 - Sigstore transparency entry: 1005366544
- Sigstore integration time:
-
Permalink:
mahdemir/pydiyanet@d211e29ee73c070a47189ac4e6d42a0ebd42782f -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/mahdemir
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d211e29ee73c070a47189ac4e6d42a0ebd42782f -
Trigger Event:
push
-
Statement type: