Pi-hole icon

Pi-hole

Get information from Pi-hole API

Actions10

Overview

This n8n node interacts with the Pi-hole API to retrieve summary statistics about blocked queries and users. The "Summary" resource with the "Get" operation fetches generic statistics, such as the number of blocked domains, total queries, and user activity. This node is useful for monitoring network-wide ad blocking performance, generating reports, or integrating Pi-hole data into dashboards and automation workflows.

Example scenarios:

  • Automatically collect daily Pi-hole usage stats for reporting.
  • Trigger alerts if the number of blocked queries exceeds a threshold.
  • Integrate Pi-hole statistics into a home automation dashboard.

Properties

Name Type Meaning
API Url String The base URL of your Pi-hole API endpoint (e.g., http://localhost/admin/api.php).

Output

The output will be a JSON object containing summary statistics from the Pi-hole API. Typical fields may include:

{
  "domains_being_blocked": 123456,
  "dns_queries_today": 7890,
  "ads_blocked_today": 2345,
  "ads_percentage_today": 29.7,
  "unique_domains": 5678,
  "queries_forwarded": 3456,
  "queries_cached": 1234,
  "clients_ever_seen": 12,
  "unique_clients": 10,
  "status": "enabled"
}

Note: The exact structure depends on the Pi-hole version and configuration, but it generally includes counts and percentages related to DNS queries and ad-blocking effectiveness.

Dependencies

  • Pi-hole API: You must have a running Pi-hole instance with its API accessible at the specified API URL.
  • API URL: Ensure the API Url property points to your Pi-hole's API endpoint (default: http://localhost/admin/api.php).
  • Credentials: No authentication is required by default, but if your Pi-hole instance is secured, you may need to provide an API token or adjust access permissions.

Troubleshooting

  • Connection Errors:
    • Error message: "Could not connect to Pi-hole API"
      • Resolution: Check that the API URL is correct and reachable from the n8n server. Ensure there are no firewall or network issues.
  • Invalid Response/Empty Data:
    • Error message: "Unexpected response format" or missing expected fields
      • Resolution: Verify that the Pi-hole API is functioning correctly and returning valid JSON. Make sure you are using a compatible Pi-hole version.
  • Authentication Issues:
    • If your Pi-hole API requires authentication, ensure you have configured credentials appropriately in n8n.

Links and References

Discussion