Pi-hole API Questions

is there a reference page with the latest API?

is it possible to get the current number of white/black list items?

Documentation for the current telnet-API is available at https://docs.pi-hole.net/ftldns/telnet-api/.

However, it doesn't allow to access the information you specifically asked for.

Also, you should be aware that the Telnet API is about to be superseded by a new API with a future Pi-hole release.

Information can also be retrieved by interacting with Pi-hole's databases via SQL.
Documentation for both of Pi-hole's databases is available at https://docs.pi-hole.net/database/.

In your case, the information you look for could be extracted by a statement like:

sqlite3 /etc/pihole/gravity.db "SELECT count(domain) \
FROM domainlist WHERE type IN (0,2);"

This will return the number of whitelist items. Changing the type match values to (1,3) will give you the number of blacklist items, respectively.
For further details, please refer to the documentation.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.