N8n node for using the Pi-hole API

Overview

n8n Pi-hole API client

Build NPM version NPM downloads

This is an N8n community node. It allows you to use the Pi-hole API [1],[2], in your workflow.

Most of the resources provided by the Pi-hole API are read only, for example the ad blocking metrics or the system status. To use these endpoints you don't need to create a credential.

However, if you plan to use the endpoints that can change the Pi-hole system status, for example disabling/enable the ad blocking, you will need to create the credential to access the API.

Please see bellow which operations are implemented by this node.

Index

Installation
Usage
Credentials
Resources/Operations
Compatibility
Developers

Installation

No special requirement for this node.

Just follow the generic installation guide in the n8n community nodes documentation.

NpmJs url: https://www.npmjs.com/package/n8n-nodes-pihole

NpmJs package name: n8n-nodes-pihole

  1. Go to Settings > Community Nodes, and Click Install a community node. n8n community node install
  2. Enter n8n-nodes-pihole in Enter npm package name input. n8n community node install pihole
  3. Click Install.

After installed you can use the search bar to add the Pi-hole node to your workflow.

pihole node search n8n pihole n8n node

Usage

The node configuration is quite simple, just specify the credentials(if required for the operation you want to perform) and the API URL. If you are using the default Pi-hole configurations the API url is http://domain/admin/api.php. For example, http://192.168.1.125/admin/api.php.

Credentials

Only the operations that can change the Pi-hole state require the usage of the API key. For example, if you want to disable or enable the ad blocking from n8n, you must create the credential. If you are only interested in "read" operations you can skip this step.

  1. First you must get the Pi-hole API key. Navigate to the Settings-> API/ Web interface, and click on the "Show API token".

pihole settings api key

  1. On the popup click on the "Yes, show API token" button.

pihole api key popup

  1. Finally copy the api key. (Yes, this is a test key)

pihole api key

  1. Back to the n8n web page, create a credential of the type "Pi-hole"

n8n credential menu

  1. Paste and save the Pi-hole API key

n8n credential pihole

Resources

This section describes which Pi-hole API operations are available in this node.

Please create an issue or submit PR if you are interested in implementing a new operation.

Resource Operation Credentials required
Status Get no
Enable yes
Disable yes
Summary Get no
ApiVersion Get no
Version Get no
Type Get no
RecentBlocked Get no
TopClients Get yes
TopClientsBlocked Get yes

Status

Get

Returns overall status of the system.

It either returns disabled or enabled. Example:

  {
    "status": "disabled"
  }

Enable - Requires credential

This operation enables the Pi-hole ad blocking.

Disable - Requires credential

This operation disables the Pi-hole ad blocking.

If you want to disable the ad blocking for specific amount of time, you can configure the "seconds" property. When specified it will disable the ad blocking for the specified amount of seconds.

Summary

Returns the summary of the system stats.

The response of this operation contains for example the number of domains blocked or the last gravity list update date. For example:

  {
    "domains_being_blocked": "906,175",
    "dns_queries_today": "29,350",
    "ads_blocked_today": "5,053",
    "ads_percentage_today": "17.2",
    "unique_domains": "3,218",
    "queries_forwarded": "18,978",
    "queries_cached": "5,238",
    "clients_ever_seen": "9",
    "unique_clients": "9",
    "dns_queries_all_types": "29,350",
    "reply_UNKNOWN": "161",
    "reply_NODATA": "6,880",
    "reply_NXDOMAIN": "1,122",
    "reply_CNAME": "8,576",
    "reply_IP": "12,267",
    "reply_DOMAIN": "235",
    "reply_RRNAME": "0",
    "reply_SERVFAIL": "17",
    "reply_REFUSED": "0",
    "reply_NOTIMP": "0",
    "reply_OTHER": "0",
    "reply_DNSSEC": "0",
    "reply_NONE": "0",
    "reply_BLOB": "92",
    "dns_queries_all_replies": "29,350",
    "privacy_level": "0",
    "status": "disabled",
    "gravity_last_updated": {
      "file_exists": true,
      "absolute": 1664313721,
      "relative": {
        "days": 3,
        "hours": 19,
        "minutes": 10
      }
    }
  }

ApiVersion

Returns the version of the API.

{
  "version": 3
}

Version

Returns the version for each Pi-hole component (core, web and ftl). Also indicates if any of the components have a pending update.

{
  "core_update": false,
  "web_update": false,
  "FTL_update": false,
  "core_current": "v5.12.2",
  "web_current": "v5.15.1",
  "FTL_current": "v5.18.1",
  "core_latest": "v5.12.2",
  "web_latest": "v5.15.1",
  "FTL_latest": "v5.18.1",
  "core_branch": "master",
  "web_branch": "master",
  "FTL_branch": "master"
}

Type

Returns the backend used by the API (either PHP or FTL).

  {
    "type": "FTL"
  }

RecentBlocked

Returns the last blocked domain.

TopClient - Requires credential

Returns the clients with the higher number of requests. By default it returns the first 10 clients, you can specify a different value in the additional properties.

[
  {
    "top_sources": {
      "DESKTOP.lan|192.168.1.245": 11057,
      "something.lan|192.168.1.102": 10707,
      "192.168.1.163": 4033,
    }
  }
]

TopClientBlocked - Requires credential

Returns the clients with the higher number of blocked requests. By default it returns the first 10 clients, you can specify a different value in the additional properties.

[
  {
    "top_sources_blocked": {
      "DESKTOP.lan|192.168.1.245": 11057,
      "something.lan|192.168.1.102": 10707,
      "192.168.1.163": 4033,
    }
  }
]

Compatibility

Tested on n8n version 0.193.5 and Pi-hole v5.12.2 | FTL v5.18.1 | Web Interface v5.15.1

Developers

//TODO

Requirements

The n8n development environment tools.

To make the development easier you can use the docker-compose.yml file to launch 2 containers, one with n8n and another with Pi-hole.

You might also like...

Apilytics for Node.js - Easy API analytics for Node backends

apilytics-node Apilytics is a service that lets you analyze operational, performance and security metrics from your APIs without infrastructure-level

Sep 2, 2022

Spin node create spin api for node

Links Contract api JS api @spinfi/core @spinfi/node @spinfi/node Spin node create spin api for node How to install yarn add @spinfi/node How to init i

Oct 18, 2022

A Weather API project inspired by The Ultimate API Challenge / Weather API.

Weather API Project A Weather API project inspired by The Ultimate API Challenge / Weather API. Tech Stack: React.js Tailwind Axios Inspiration The Pr

Dec 29, 2021

This project is built with JavaScript, Webpack, HTML & CSS, Leaderboard api. When user clicks on Refresh button it hits the api and responds with the data, The user can also post data to the api

This project is built with JavaScript, Webpack, HTML & CSS, Leaderboard api. When user clicks on Refresh button it hits the api and responds with the data, The user can also post data to the api

leaderboad Description the project. this project is about the leaderboad i did during Microverse to build a website for adding Data to the API and fet

May 30, 2022

Set up and build a Node.js REST API using Typescript, Express, Mongoose with a maintainable and scalable structure.

Introduction Create a maintainable and scalable Node.js REST API with TypeScript, Express and Mongoose. The project structure is based on MVC and foll

Nov 18, 2022

Node.js library for creating bots and sending/receiving messages using the Whatsapp Cloud API

whatsapp-cloud-api whatsapp-cloud-api is a Node.js library for creating bots and sending/receiving messages using the Whatsapp Cloud API. Contains bui

Jan 2, 2023

🚌 A Node.js API to access public transport information in Lisbon using data provided by Carris Metropolitana

🚌 Carris Metropolitana API A Node.js REST API built to easily access and search public transport information in Lisbon using data provided by Carris

Jun 21, 2022

API is made using node-js

Project Setup In order to run the project: Create .env in the root with these two variables, with your own values. MONGO_URI JWT_SECRET After that run

Oct 9, 2022

An unofficial wrapper for the Bloxlink API using Node.js

Bloxlink API wrapper 🧬 Bloxlink-sdk is a simple, easy to use API wrapper for Bloxlinks API using Node.js. Anyone who can use code should be fairly co

Oct 21, 2022
Releases(1.1.0)
  • 1.1.0(Oct 10, 2022)

    What's Changed

    • Implement version resource that fetches the versions of each Pi-hole component by @hugo-ma-alves in https://github.com/hugo-ma-alves/n8n-nodes-pihole/pull/1
    • Implement TopClient and TopClientBlocked API request by @hugo-ma-alves in https://github.com/hugo-ma-alves/n8n-nodes-pihole/pull/2

    Full Changelog: https://github.com/hugo-ma-alves/n8n-nodes-pihole/compare/1.0.0...1.1.0

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Oct 1, 2022)

    First Release

    Implements the following operations:

    • Status - get/enable/Disable
    • Summary - get
    • Version - get
    • Type - get
    • RecentBlocked - get

    Full Changelog: https://github.com/hugo-ma-alves/n8n-nodes-pihole/commits/1.0.0

    Source code(tar.gz)
    Source code(zip)
Owner
Hugo Alves
Java software engineer
Hugo Alves
[WIP] n8n nodes that cover the Zoho "Books" API

n8n-nodes-starter This repo contains example nodes to help you get started building your own custom integrations for n8n. It includes the node linter

Vrishin Patel 6 Nov 26, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
This is 2D Black Hole Visualization

Blackhole Live demo Blackhole Calculations How to run in your machine? Clone or download ZIP file Then open HTML file in VS code and run with live ser

Nikhil Yadav 13 Jan 7, 2023
Synchronize multiple Pi-hole instances

Orbital Sync Orbital Sync synchronizes multiple Pi-hole instances for high availability (HA) using the built-in "teleporter". In other words, it perfo

Matt Webb 32 Dec 30, 2022
Website to test solving the rabbit hole challenge.

?? Rabbit in the Hole Challenge This website is designed to show solutions and possibilities for the Rabbit in the Hole Challenge. ?? What is the chal

Nícolas Gabriel 5 Oct 18, 2022
Use Cloudflare Gateway DNS/VPN to block ads, malware and tracking domains - free alternative to NextDNS, Pi-hole and Adguard

Cloudflare Gateway Pi-hole Scripts (CGPS) Cloudflare Gateway allows you to create custom rules to filter HTTP, DNS, and network traffic based on your

null 70 Aug 13, 2023
This is a vanilla Node.js rest API created to show that it is possible to create a rest API using only vanilla Node.js

This is a vanilla Node.js rest API created to show that it is possible to create a rest API using only vanilla Node.js. But in most cases, I would recommend you to use something like Express in a production project for productivity purposes.

Eduardo Dantas 7 Jul 19, 2022
Node 18's node:test, as a node module

node-core-test This is a user-land port of node:test, the experimental test runner introduced in Node.js 18. This module makes it available in Node.js

Julian Gruber 62 Dec 15, 2022