pihole6api


Namepihole6api JSON
Version 0.1.3 PyPI version JSON
download
home_pageNone
SummaryPython API Client for Pi-hole 6
upload_time2025-02-23 03:08:56
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords pihole dns adblocking api client
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 🍓 pihole6api

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

## Features

* Automatically handles authentication and renewal
* Gracefully error management
* Logically organized modules
* Easily maintained

## Installation

**Install using `pip` or `pipx`:**

```bash
pip install pihole6api
```

**Install from source:**

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

## Quick Start

### Initialize the Client

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

### Example Usage

#### Get Pi-Hole Metrics

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

#### Enable/Disable Blocking

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

#### Manage Groups

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

#### Manage Domains

```python
client.domain_management.add_domain("ads.example.com", "deny", "exact")
client.domain_management.delete_domain("ads.example.com", "deny", "exact")
```

#### Manage Links

```python
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

```python
# 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

```python
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 |
| `padd`              | Fetch summarized data for PADD |

## License

This project is license under the [MIT license](LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pihole6api",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "pihole, dns, adblocking, api, client",
    "author": null,
    "author_email": "Shane Barbetta <shane@barbetta.me>",
    "download_url": "https://files.pythonhosted.org/packages/31/67/f861d3abaa15b53ce8296383e93b6cbb63a247335a9fedcd9527f9e9533f/pihole6api-0.1.3.tar.gz",
    "platform": null,
    "description": "# \ud83c\udf53 pihole6api\n\nThis package provides a simple, modular SDK for the PiHole 6 REST API.\n\n## Features\n\n* Automatically handles authentication and renewal\n* Gracefully error management\n* Logically organized modules\n* Easily maintained\n\n## Installation\n\n**Install using `pip` or `pipx`:**\n\n```bash\npip install pihole6api\n```\n\n**Install from source:**\n\n```bash\ngit clone https://github.com/sbarbett/pihole6api.git\ncd pihole6api\npip install -e .\n```\n\n## Quick Start\n\n### Initialize the Client\n\n```python\nfrom pihole6api import PiHole6Client\nclient = PiHole6Client(\"https://your-pihole.local/\", \"your-password\")\n```\n\n### Example Usage\n\n#### Get Pi-Hole Metrics\n\n```python\nhistory = client.metrics.get_history()\nprint(history)  # {'history': [{'timestamp': 1740120900, 'total': 0, 'cached': 0 ...}]}\nqueries = client.metrics.get_queries()\nprint(queries)\n```\n\n#### Enable/Disable Blocking\n\n```python\nclient.dns_control.set_blocking_status(False, 60)\nprint(client.dns_control.get_blocking_status()) # {'blocking': 'disabled', 'timer': 60 ...}\n```\n\n#### Manage Groups\n\n```python\nclient.group_management.add_group(\"Custom Group\", comment=\"For testing\")\nclient.group_management.delete_group(\"Custom Group\")\n```\n\n#### Manage Domains\n\n```python\nclient.domain_management.add_domain(\"ads.example.com\", \"deny\", \"exact\")\nclient.domain_management.delete_domain(\"ads.example.com\", \"deny\", \"exact\")\n```\n\n#### Manage Links\n\n```python\nclient.list_management.add_list(\"https://example.com/blocklist.txt\", \"block\")\nclient.list_management.delete_list(\"https://example.com/blocklist.txt\", \"block\")\n```\n\n#### Export/Import PiHole Settings\n\n```python\n# Export settings and save as a .zip file\nwith open(\"pihole-settings.zip\", \"wb\") as f:\n    f.write(client.config.export_settings())\n\nclient.config.import_settings(\"pihole-settings.zip\", {\"config\": True, \"gravity\": {\"group\": True}})\n```\n\n#### Flush Logs & Restart DNS\n\n```python\nclient.actions.flush_logs()\nclient.actions.restart_dns()\n```\n\n## API Modules\n\n| Module                | Description |\n|----------------------|-------------|\n| `metrics`           | Query history, top clients/domains, DNS stats |\n| `dns_control`       | Enable/disable blocking |\n| `group_management`  | Create, update, and delete groups |\n| `domain_management` | Allow/block domains (exact & regex) |\n| `client_management` | Manage client-specific rules |\n| `list_management`   | Manage blocklists (Adlists) |\n| `config`            | Modify Pi-hole configuration |\n| `ftl_info`          | Get Pi-hole core process (FTL) info |\n| `dhcp`              | Manage DHCP leases |\n| `network_info`      | View network devices, interfaces, routes |\n| `actions`           | Flush logs, restart services |\n| `padd`              | Fetch summarized data for PADD |\n\n## License\n\nThis project is license under the [MIT license](LICENSE).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python API Client for Pi-hole 6",
    "version": "0.1.3",
    "project_urls": {
        "Documentation": "https://github.com/sbarbett/pihole6api",
        "Homepage": "https://github.com/sbarbett/pihole6api",
        "Issues": "https://github.com/sbarbett/pihole6api/issues",
        "Source": "https://github.com/sbarbett/pihole6api"
    },
    "split_keywords": [
        "pihole",
        " dns",
        " adblocking",
        " api",
        " client"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a2f729d5aec03340aa80e09b83a7787b64b896cb89ac35a8a121c2cc81b47263",
                "md5": "1c16ded2f042ba4b147d064575f5da14",
                "sha256": "e784a97649c3fd54d87ccb4f827885551a5d504864d1398b3e78bb3f1764f3a8"
            },
            "downloads": -1,
            "filename": "pihole6api-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1c16ded2f042ba4b147d064575f5da14",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 15431,
            "upload_time": "2025-02-23T03:08:55",
            "upload_time_iso_8601": "2025-02-23T03:08:55.358992Z",
            "url": "https://files.pythonhosted.org/packages/a2/f7/29d5aec03340aa80e09b83a7787b64b896cb89ac35a8a121c2cc81b47263/pihole6api-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3167f861d3abaa15b53ce8296383e93b6cbb63a247335a9fedcd9527f9e9533f",
                "md5": "b632bbace811685f62e57d87ca960e7d",
                "sha256": "c8878652bb53ba08f16bb796e90aeafa61d644e47c5b1a3e3e7c67026026c4e4"
            },
            "downloads": -1,
            "filename": "pihole6api-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "b632bbace811685f62e57d87ca960e7d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 12100,
            "upload_time": "2025-02-23T03:08:56",
            "upload_time_iso_8601": "2025-02-23T03:08:56.257320Z",
            "url": "https://files.pythonhosted.org/packages/31/67/f861d3abaa15b53ce8296383e93b6cbb63a247335a9fedcd9527f9e9533f/pihole6api-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-23 03:08:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sbarbett",
    "github_project": "pihole6api",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pihole6api"
}
        
Elapsed time: 0.57559s