Skip to main content

🍓 pihole6api

This package provides a simple, modular SDK for the PiHole 6 REST API.

Features

  • Automatically handles authentication and renewal
  • Graceful error management
  • Logically organized modules
  • Easily maintained

Installation

Install using pip:

pip install pihole6api

Install from source:

git clone https://github.com/sbarbett/pihole6api.git
cd pihole6api
pip install -e .

Quick Start

Initialize the Client

from pihole6api import PiHole6Client
client = PiHole6Client("https://your-pihole.local/", "your-password")

Example Usage

Get Pi-Hole Metrics

history = client.metrics.get_history()
print(history)  # {'history': [{'timestamp': 1740120900, 'total': 0, 'cached': 0 ...}]}
queries = client.metrics.get_queries()
print(queries)

Enable/Disable Blocking

client.dns_control.set_blocking_status(False, 60)
print(client.dns_control.get_blocking_status()) # {'blocking': 'disabled', 'timer': 60 ...}

Manage Groups

client.group_management.add_group("Custom Group", comment="For testing")
client.group_management.delete_group("Custom Group")

Manage Domains

client.domain_management.add_domain("ads.example.com", "deny", "exact")
client.domain_management.delete_domain("ads.example.com", "deny", "exact")
client.list_management.add_list("https://example.com/blocklist.txt", "block")
client.list_management.delete_list("https://example.com/blocklist.txt", "block")

Export/Import PiHole Settings

# Export settings and save as a .zip file
with open("pihole-settings.zip", "wb") as f:
    f.write(client.config.export_settings())

client.config.import_settings("pihole-settings.zip", {"config": True, "gravity": {"group": True}})

Flush Logs & Restart DNS

client.actions.flush_logs()
client.actions.restart_dns()

API Modules

Module Description
metrics Query history, top clients/domains, DNS stats
dns_control Enable/disable blocking
group_management Create, update, and delete groups
domain_management Allow/block domains (exact & regex)
client_management Manage client-specific rules
list_management Manage blocklists (Adlists)
config Modify Pi-hole configuration
ftl_info Get Pi-hole core process (FTL) info
dhcp Manage DHCP leases
network_info View network devices, interfaces, routes
actions Flush logs, restart services

Contributing

Please check CONTRIBUTING.md for contribution guidelines.

Changelog

See CHANGELOG.md for a list of changes.

License

This project is license under the MIT license.

Metadata

Release files for pihole6api 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pihole6api 0.2.1
File Size Uploaded Provenance Actions
pihole6api-0.2.1.tar.gz 14.1 kB Without provenance Details for pihole6api-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pihole6api 0.2.1
File Interpreter ABI Platform Actions
pihole6api-0.2.1-py3-none-any.whl Python 3 none any Details for pihole6api-0.2.1-py3-none-any.whl

Total release size: 31.6 kB

Release files / pihole6api-0.2.1.tar.gz

Download URL pihole6api-0.2.1.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
cbf416bc868dce4076d26780c5495e4496d8960ad2e8a9794cc78e1ab93233f9
BLAKE2b-256 checksum
How to use checksums
57e91dd06bee9b41c1b0d83ca8b31330cf21e9cca38d655a97e83a70bef772dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / pihole6api-0.2.1-py3-none-any.whl

Download URL pihole6api-0.2.1-py3-none-any.whl
Size 17.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc8775932cff7cee73d41e4e2ecbebb7b5c92e1c4fed1eab4de1ffbfafecf277
BLAKE2b-256 checksum
How to use checksums
cfa316803cf5cf9a62072ed198ceda811ba42bcd74ff8e6e67dced2936573941
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Security for pihole6api 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page