If there was a RESTful (or similar) API, it would open the world to accessing the Pi-hole. A developer could write an extension that could turn the Pi-hole off and on; add sites to the white and blacklist or change the blocklists.
The two way nature of an API could be useful in showing stats without having the need to have a web browser open.
For the shell lovers:
pi@noads:~ $ surfraw duckduckgo -l pihole restful api
Announcing Our RESTful API — Contributions Welcome – Pi-hole®: A blac (p1 of 9)
Link: profile
Link: prev: What Really Happens On Your Network? Part Eight
Link: next: Pi-hole As A Snapcraft Package
Link: canonical
Link: shortlink
Pi-hole®: A black hole for Internet advertisements
* GitHub
* Core
* Web
* FTL
* API
* Docker
* Community
* Log in with Discourse
* My Account
* Discourse
* Reddit
* Twitter
* About
* Documentation
* Contact
* Privacy
http://gmpg.org/xfn/11
From the readme.md:
Work in progress HTTP API for Pi-hole. It accesses the internal FTL API through a Unix domain socket
Domain sockets only work on the server. What I was meaning was something like:
http://pi.hole/api?key=key&secret=secret&cmd=disable
So a 3rd party developer could access the Pi-hole remotely with a shared key and secret.
https://pi-hole.net/2018/10/15/announcing-our-restful-api-contributions-welcome/
"the API will host the Web interface"
"The API exposes a RESTful HTTP API which is used by the web interface"
Yes oc a socket, the TCP 80 or 443 one
Mcat12
March 21, 2019, 2:11am
6
There is more information and up to date code available on the development branch: GitHub - pi-hole/api at development
This API does host a HTTP interface. An example request would be:
GET http://pi.hole/admin/api/stats/summary
X-Pi-hole-Authenticate: <secret_here>
Response (dev server, so not many blocked queries):
{
"active_clients": 1,
"blocked_queries": 0,
"cached_queries": 0,
"forwarded_queries": 33442,
"gravity_size": 112866,
"percent_blocked": 0.0,
"reply_types": {
"CNAME": 0,
"DOMAIN": 0,
"IP": 0,
"NODATA": 0,
"NXDOMAIN": 0
},
"status": "enabled",
"total_clients": 1,
"total_queries": {
"A": 16673,
"AAAA": 16673,
"ANY": 0,
"PTR": 96,
"SOA": 0,
"SRV": 0,
"TXT": 0
},
"unique_domains": 16
}
2 Likes
API Endpoints for list manipulations in pihole v5.0
pi-hole:devel
← pi-hole:new/api_add_sub_get_lists
opened 04:39PM - 26 May 20 UTC
**By submitting this pull request, I confirm the following:**
- [X] I have r… ead and understood the [contributors guide](https://github.com/pi-hole/pi-hole/blob/master/CONTRIBUTING.md), as well as this entire template.
- [X] I have made only one major change in my proposed changes.
- [X] I have commented my proposed changes within the code.
- [X] I have tested my proposed changes, and have included unit tests where possible.
- [X] I am willing to help maintain this change if there are issues with it later.
- [X] I give this submission freely and claim no ownership.
- [X] It is compatible with the [EUPL 1.2 license](https://opensource.org/licenses/EUPL-1.1)
- [X] I have squashed any insignificant commits. ([`git rebase`](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html))
---
**What does this PR aim to accomplish?:**
- Fix #1297
- Finally get rid of the remaining `add.php` and use the `groups.php` routines for everything (eases maintenance).
**How does this PR accomplish the above?:**
Add API endpoints `api.php?list=black&add=domain.com` like commands where `add=domain` and `sub=domain` can be used to manage the lists. A simple `api.php?list=black` will simply list all blacklisted domains.
`list` can be `black`, `white`, `regex_white` and `regex_black`.
**What documentation changes (if any) are needed to support this PR?:**
None