Giter VIP home page Giter VIP logo

pihole-client's Introduction

Installation

Before using this Pihole API client, ensure you have Python and the requests library installed. You can install requests using pip:

pip install requests

or use the requirements file

pip install -r requirements.txt

Usage

First, import the PiholeClient from the module:

from pihole_client import PiholeClient

Then, create an instance of the PiholeClient by providing the address of your Pihole server and, optionally, your API token:

client = PiholeClient('http://pi.hole', api_token='YourApiToken')

Filtering Control

These methods are used to enable or disable the Pihole ad filtering.

enable()

Enables the Pihole filtering.

Example:

client.enable()

disable(seconds=0)

Disables the Pihole filtering for a specified duration. If no duration is provided, filtering is disabled indefinitely.

Example:

client.disable(300)  # Disables for 5 minutes

Update Checks

This method checks for updates to the Pihole software.

check_updates()

Example:

client.check_updates()

Temperature Unit Setting

This method sets the temperature unit displayed in the Pihole interface.

set_temperature_unit(unit)

Valid units are 'c', 'f', and 'k'.

Example:

client.set_temperature_unit('f')

List Management

These methods are used to add, remove, and retrieve domains from Pihole's various lists.

add_to_list(list_type, domain)

Adds a domain to one of the specified lists: 'black', 'regex_black', 'white', or 'regex_white'.

Example:

client.add_to_list('black', 'example.com')

remove_from_list(list_type, domain)

Removes a domain from one of the specified lists.

Example:

client.remove_from_list('white', 'example.com')

get_lists(list_type)

Retrieves all domains in a specified list.

Example:

domains = client.get_lists('black')

Custom DNS Management

These methods are used to manage custom DNS settings, allowing for specific domain-to-IP address mappings.

get_custom_dns()

Retrieves all custom DNS settings.

Example:

custom_dns = client.get_custom_dns()

add_custom_dns(domain, ip)

Adds a custom DNS entry.

Example:

client.add_custom_dns('example.com', '192.168.1.100')

delete_custom_dns(domain, ip)

Deletes a custom DNS entry.

Example:

client.delete_custom_dns('example.com', '192.168.1.100')

Custom CNAME Management

These methods are used to manage custom CNAME records, facilitating domain aliasing within the network.

get_custom_cname()

Retrieves all custom CNAME settings.

Example:

custom_cname = client.get_custom_cname()

add_custom_cname(domain, target)

Adds a custom CNAME entry.

Example:

client.add_custom_cname('portal.example.com', 'internal.example.com')

delete_custom_cname(domain, target)

Deletes a custom CNAME entry.

Example:

client.delete_custom_cname('portal.example.com', 'internal.example.com')

Each of these groups provides a coherent set of functionalities that you can use to manage your Pihole's behavior and settings effectively. Remember to handle any exceptions these methods may throw, especially when dealing with network or API issues.

License

The software is released under the MIT License. See the LICENSE file for more details.

pihole-client's People

Contributors

lfanew avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.