API for pihole
Project description
pi_hole_api
Python api module for pi-hole server (https://pi-hole.net/). Execute api calls to py-hole server from python code.
Installation
# prod version:
pip install pi-hole-api
# dev version:
pip install -i https://test.pypi.org/simple/ pi-hole-api
Examples
Create class
import pihole_api as pi
pihole = pi.Pihole("PI_URL", "PI_PSW")
where:
- PI_URL: url of pi-hole page
- PI_PSW: password of pi-hole
or using environment variables "PI_URL" and "PI_PSW" set to pi-hole url and pi-hole password respectively:
import os
from dotenv import load_dotenv
import pihole_api as pi
pihole = pi.Pihole(os.environ["PI_URL"], os.environ["PI_PSW"])
Core module
Permit:
- enable/disable protection
pihole.enable()
pihole.disable()
pihole.disable(30) # disable per 30 seconds
Dns module
Permit:
- list dns records
- add/remove A record
- add/remove CNAME record
pihole.dns("get") # print dns list
pihole.cname("get") # print cname list
# add domain to dns
pihole.dns("add", ip_address="1.1.1.1",domain="pippo.com"))
# remove domain to dns
pihole.dns("delete", ip_address="1.1.1.1",domain="pippo.com"))
# add cname from pippo.com to pluto.com
pihole.cname("add","pippo.com","pluto.com"))
# remove cname
pihole.cname("delete","pippo.com","pluto.com"))
List module
Permit:
- list/add/change/remove domains to white lists
- list/add/change/remove domains to black lists
# get white list
pihole.get_domains("white")
# add to white list
pihole.add_domain("white","pippo.it","add pippo")
# replace in white list
pihole.replace_domain("white","pippo.it","replace pippo")
# delete from white list
pihole.delete_domain("white","pippo.it","delete pippo")
# get black list
pihole.get_domains("black")
# add to black list
pihole.add_domain("black","pippo.it","add pippo")
# add change in black list
pihole.replace_domain("black","pippo.it","replace pippo")
# delete from black list
pihole.delete_domain("black","pippo.it","delete pippo")
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
pi_hole_api-0.1.3.tar.gz
(4.5 kB
view hashes)
Built Distribution
Close
Hashes for pi_hole_api-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1911c789419e101d5ba815e6916c21f4a0b7423cc2d9d2b5b09f911c22c3e86c |
|
MD5 | 62d2cfd4313aad92c211097de5891d1e |
|
BLAKE2b-256 | 2b616ac9c5e42b5b0f72e9cbc31377dbea749be9ff49560907a5034bf004ef71 |