mirror of
https://github.com/pi-hole/docs.git
synced 2024-12-06 19:27:12 +01:00
Add documentation for single GET requests
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
+90
-6
@@ -23,8 +23,8 @@ None
|
||||
=== "cURL"
|
||||
|
||||
``` bash
|
||||
curl -H "Authorization: Token <your-access-token>" \
|
||||
http://pi.hole:8080/admin/api/whitelist/exact
|
||||
curl http://pi.hole:8080/admin/api/whitelist/exact \
|
||||
-H "Authorization: Token <your-access-token>"
|
||||
```
|
||||
|
||||
=== "Python 3"
|
||||
@@ -41,6 +41,88 @@ None
|
||||
print(response.json())
|
||||
```
|
||||
|
||||
!!! success "Success response"
|
||||
|
||||
Response code: `HTTP/1.1 200 OK`
|
||||
|
||||
``` json
|
||||
[
|
||||
{
|
||||
"domain": "whitelisted.com",
|
||||
"enabled": true,
|
||||
"date_added": 1589108911,
|
||||
"date_modified": 1589108911,
|
||||
"comment": ""
|
||||
},
|
||||
{
|
||||
"domain": "whitelisted2.com",
|
||||
"enabled": false,
|
||||
"date_added": 1589104951,
|
||||
"date_modified": 1589104951,
|
||||
"comment": ""
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
!!! failure "Error response (database not available)"
|
||||
|
||||
Response code: `HTTP/1.1 402 - Request failed`
|
||||
|
||||
``` json
|
||||
{
|
||||
"error": {
|
||||
"key": "database_error",
|
||||
"message": "Could not remove domain to gravity database",
|
||||
"data": {
|
||||
"sql_msg": "Database not available"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
<!-- markdownlint-enable code-block-style -->
|
||||
|
||||
## GET: List specific item
|
||||
|
||||
Resources:
|
||||
|
||||
- `GET /admin/api/whitelist/exact/<domain>`
|
||||
- `GET /admin/api/whitelist/regex/<domain>`
|
||||
- `GET /admin/api/blacklist/exact/<domain>`
|
||||
- `GET /admin/api/blacklist/regex/<domain>`
|
||||
|
||||
Requires authorization: Yes
|
||||
|
||||
### Parameters
|
||||
|
||||
The domain/regex to be listed is specified through the URL (`<domain>`).
|
||||
|
||||
### Example
|
||||
|
||||
<!-- markdownlint-disable code-block-style -->
|
||||
!!! example "Request"
|
||||
|
||||
=== "cURL"
|
||||
|
||||
``` bash
|
||||
curl http://pi.hole:8080/admin/api/whitelist/exact/whitelisted.com \
|
||||
-H "Authorization: Token <your-access-token>"
|
||||
```
|
||||
|
||||
=== "Python 3"
|
||||
|
||||
``` python
|
||||
import requests
|
||||
|
||||
URL = 'http://pi.hole:8080/admin/api/whitelist/exact/'
|
||||
TOKEN = '<your-access-token>'
|
||||
HEADERS = {'Authorization': f'Token {TOKEN}'}
|
||||
|
||||
domain = 'whitelisted.com'
|
||||
response = requests.get(URL + domain, headers=HEADERS)
|
||||
|
||||
print(response.json())
|
||||
```
|
||||
|
||||
!!! success "Success response"
|
||||
|
||||
Response code: `HTTP/1.1 200 OK`
|
||||
@@ -182,7 +264,8 @@ The domain/regex to be removed is specified through the URL (`<domain>`).
|
||||
**Domain**
|
||||
|
||||
``` bash
|
||||
curl http://pi.hole:8080/admin/api/whitelist/exact/whitelisted.com \
|
||||
domain="whitelisted.com"
|
||||
curl http://pi.hole:8080/admin/api/whitelist/exact/${domain} \
|
||||
-X DELETE \
|
||||
-H "Authorization: Token <your-access-token>"
|
||||
```
|
||||
@@ -203,11 +286,12 @@ The domain/regex to be removed is specified through the URL (`<domain>`).
|
||||
``` python
|
||||
import requests
|
||||
|
||||
URL = 'http://pi.hole:8080/admin/api/whitelist/exact/whitelisted.com'
|
||||
URL = 'http://pi.hole:8080/admin/api/whitelist/exact/'
|
||||
TOKEN = '<your-access-token>'
|
||||
HEADERS = {'Authorization': f'Token {TOKEN}'}
|
||||
|
||||
response = requests.delete(URL, headers=HEADERS)
|
||||
domain = 'whitelisted.com'
|
||||
response = requests.delete(URL + domain, headers=HEADERS)
|
||||
|
||||
print(response.json())
|
||||
```
|
||||
@@ -218,11 +302,11 @@ The domain/regex to be removed is specified through the URL (`<domain>`).
|
||||
import requests
|
||||
import urllib
|
||||
|
||||
regex = urllib.parse.quote("(^|\\.)facebook.com$")
|
||||
URL = 'http://pi.hole:8080/admin/api/whitelist/exact/'
|
||||
TOKEN = '<your-access-token>'
|
||||
HEADERS = {'Authorization': f'Token {TOKEN}'}
|
||||
|
||||
regex = urllib.parse.quote("(^|\\.)facebook.com$")
|
||||
response = requests.delete(URL + regex, headers=HEADERS)
|
||||
|
||||
print(response.json())
|
||||
|
||||
Reference in New Issue
Block a user