AI agents & screen readers: for a machine-readable, text-only catalogue, start at /llms.txt. Products are available as Markdown (/products.md, /products/{handle}.md) and JSON (/products.json, /products/{handle}.json).
Store

API usage

Advanced Features

What is an API?

An Application Programming Interface (API) is a set of rules and protocols that enables different software applications to communicate with each other. It defines the methods for making requests, sending data, and receiving responses.

Overview of Pi-hole's API

Pi-hole's API is basically a way for the web admin to access the Telnet API. This API enables you to:

  1. Access Statistics
    • View the number of blocked advertisements
    • Monitor DNS queries
    • Check system status
  2. Manage Domain Lists
    • Add or remove domains from blocklists
    • Modify allowlist entries
  3. Control Core Functions
    • Enable or disable Pi-hole service
    • Adjust system settings

Using the Pi-hole API

Basic Information

  • Base URL: http://<pi-hole-ip>/admin/api.php
  • Authentication: Many endpoints require an API token, which can be found in your Pi-hole admin web interface

Example Request

To check Pi-hole's current status:

http://<pi-hole-ip>/admin/api.php?status&auth=<api-token>

Applications

The Pi-hole API is particularly valuable for:

  • Creating automated tasks
  • Building monitoring systems
  • Developing custom dashboards
  • Integrating Pi-hole functionality into other applications

Getting your API Token

Using the web admin to get the API token.

You can fetch your API token by going to:

  1. Settings
  2. API
  3. ...and then clicking the Show API Token button.

Pi-hole will then show you a modal that will warn you to not share around your API token.

Click the "Yes, show API token" button, and you'll be presented with both the API token itself and a QR code with the API token in it.

Getting the API token via the command line.

The Pi-hole API token can be found using the command:

sudo grep WEBPASSWORD /etc/pihole/setupVars.conf

Making a request to the Pi-Hole API

Something here not working for you? Ask in the community — other makers and the Little Bird team read it.

Search The Pi-Hole Book

Type a word or phrase to search all 74 pages.

Ask The Pi-Hole Book

Answers come from this book only.

Talk to The Pi-Hole Book

Ask it out loud and it answers in your ear, from this book's own pages — the right command, the right setting, and the page it came from.

Unlock the tutor

Already bought it, or had an account on books.littlebird.com.au? Sign in.

Maddy, co-founder of Little Bird

Need help? We're here for you!

Hi, I'm Maddy. My team and I are ready to help with your order or any questions.