Execute API calls to Pi-hole from python code
Project description
pihole-client
Python client for Pi-hole
Installation
pip install pihole-client
Examples
Create class
from pihole_client import PiholeClient
piholeClient = PiholeClient( "PIHOLE_DOMAIN", "PIHOLE_TOKEN" )
where:
- PIHOLE_DOMAIN: URL of Pi-hole WebUi page
- PIHOLE_TOKEN: Token of Pi-hole WebUi
or using environment variables "PIHOLE_DOMAIN" and "PIHOLE_TOKEN":
from dotenv import load_dotenv
import os
from pihole_client import PiholeClient
load_dotenv()
def main():
piholeClient = PiholeClient(
os.getenv('PIHOLE_DOMAIN'),
os.getenv('PIHOLE_TOKEN')
)
resp = piholeClient.get_custom_dns()
print(resp)
if __name__ == "__main__":
main()
Methods
# Checks for updates to the Pihole software
piholeClient.check_updates()
# Enables the Pihole filtering
piholeClient.enable()
# Disables the Pihole filtering
piholeClient.disable()
# Retrieves the domains in a specified list
piholeClient.get_list("regex_black")
# Retrieves custom DNS entries
piholeClient.get_custom_dns()
# Retrieves custom DNS entrie by domain
piholeClient.get_custom_dns_by_domain("home.homelab.lan")
# Add a custom DNS entry
piholeClient.add_custom_dns(domain="router.homelab.lan", ip_address="192.168.1.1")
# Delete a custom DNS entry
piholeClient.delete_custom_dns(domain="router.homelab.lan", ip_address="192.168.1.1")
# Retrieves custom CNAME entries
piholeClient.get_custom_cname()
# Add a custom CNAME entry
piholeClient.add_custom_cname(domain="router.homelab.lan", target="xiaomi.local")
# Delete a custom CNAME entry
piholeClient.delete_custom_cname(domain="router.homelab.lan", target="xiaomi.local")
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
pihole_client-1.0.0.tar.gz
(3.9 kB
view details)
File details
Details for the file pihole_client-1.0.0.tar.gz
.
File metadata
- Download URL: pihole_client-1.0.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 366c20f3a2e5020a6941e064421f7de8fe762de95c4b63c05c1de285ee58b519 |
|
MD5 | 91a0234bcd80e6995d2e55e79082e0b5 |
|
BLAKE2b-256 | da38fbcc5aa8be22d5bddb4ab3962f5b897a9216609f1b14cd6ba8fecf034b79 |