A REST API client for pihole v6
Project description
pyhole6 API Client
pyhole6 is an asynchronous Python client for interacting with the Pi-hole v6.0 REST API. It provides a simple interface to perform various operations on your Pi-hole server.
Features
- Asynchronous API calls using aiohttp
- Automatic session management
- Logging with local timestamps
- Easy-to-use methods for common Pi-hole operations
Installation
pip install pyhole6
Usage
Initializing the Client
from pyhole6 import pyhole6
import asyncio
async def main():
client = pyhole6("http://pi.hole", "your_password")
await client.connect()
# Use the client here
await client.disconnect()
asyncio.run(main())
Using as a Context Manager
async with pyhole6("http://pi.hole", "your_password") as client:
# Use the client here
Available Methods
Get Statistics
stats = await client.get_stats()
print(stats)
Disable Blocking
# Disable blocking for 5 minutes (300 seconds)
result = await client.disable_blocking(duration=300)
print(result)
Enable Blocking
# Enable blocking immediately
result = await client.enable_blocking()
print(result)
Get Blocking Status
status = await client.get_blocking_status()
print(status)
Get Host Information
host_info = await client.get_host_info()
print(host_info)
Get Version Information
version_info = await client.get_version_info()
print(version_info)
Logging
The client includes built-in logging with local timestamps. You can access the logger through client.logger:
client.logger.info("Custom log message")
Error Handling
The client will raise exceptions for authentication failures and other API errors. It's recommended to use try-except blocks when making API calls:
try:
await client.connect()
stats = await client.get_stats()
except Exception as e:
print(f"An error occurred: {e}")
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the GPLv3 License.
---
Answer from Perplexity: pplx.ai/share
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
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 pyhole6-0.0.1.tar.gz.
File metadata
- Download URL: pyhole6-0.0.1.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.9.6 Darwin/24.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
caa23fe87806afc0dd9395b3cb0e3e30acec722ee15a1ff8ac6391ad02d9f158
|
|
| MD5 |
08a08b42a222c50c3c380696c953c734
|
|
| BLAKE2b-256 |
e60f55be65761472264c0f03461048421c8904fbb7f31ed300b3f72ae60535e3
|
File details
Details for the file pyhole6-0.0.1-py3-none-any.whl.
File metadata
- Download URL: pyhole6-0.0.1-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.9.6 Darwin/24.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbfc652d8e5bf531e06220b110e257f1687715e02a178a0ac4d7e26bdeed0dbe
|
|
| MD5 |
81c683bb3b06ea243cfbb45d12ff00c3
|
|
| BLAKE2b-256 |
a623cae232ed2c507728986582e377f6926638aa6a868fdd0d444db73184e96f
|