Is it possible to iterate into one of the JSON values with the pihole api command?
Eg if I have below:
$ sudo -u pihole pihole api stats/summary
{
"queries": {
"total": 943,
"blocked": 0,
"percent_blocked": 0,
"unique_domains": 2454,
"forwarded": 219,
"cached": 602,
"frequency": 0.03333333333333333,
"types": {
"A": 725,
"AAAA": 120,
[..]
Can I do below somehow?
sudo -u pihole pihole api stats/summary/queries/types/A
Instead of:
$ sudo -u pihole pihole api stats/summary | jq -r '.queries.types.A'
725
Usually you don't ask things like that without trying... HAHAHAH.
No.
This is not possible.
pihole api
is not a complete API interface and only returns a limited set of endpoints, but the output is a plain JSON, which simplifies a lot the use of tools like jq
.
1 Like
Oh yes i tried many ways
Thx!
EDIT: Oh for those reading along, below are the ones you can GET :
$ sudo -u pihole pihole api endpoints | jq '.endpoints.get'
[
{
"uri": "/api/auth/sessions",
"parameters": ""
},
{
"uri": "/api/auth/app",
"parameters": ""
},
{
"uri": "/api/auth/totp",
"parameters": ""
},
{
"uri": "/api/auth",
"parameters": ""
},
{
"uri": "/api/dns/blocking",
"parameters": ""
},
[..]
system
Closed
October 1, 2025, 9:18pm
4
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.