diff --git a/docs/api/domainlists.md b/docs/api/domainlists.md index f4550fa..3c927da 100644 --- a/docs/api/domainlists.md +++ b/docs/api/domainlists.md @@ -23,8 +23,8 @@ None === "cURL" ``` bash - curl -H "Authorization: Token " \ - http://pi.hole:8080/admin/api/whitelist/exact + curl http://pi.hole:8080/admin/api/whitelist/exact \ + -H "Authorization: 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" + } + } + } + ``` + + +## GET: List specific item + +Resources: + +- `GET /admin/api/whitelist/exact/` +- `GET /admin/api/whitelist/regex/` +- `GET /admin/api/blacklist/exact/` +- `GET /admin/api/blacklist/regex/` + +Requires authorization: Yes + +### Parameters + +The domain/regex to be listed is specified through the URL (``). + +### Example + + +!!! example "Request" + + === "cURL" + + ``` bash + curl http://pi.hole:8080/admin/api/whitelist/exact/whitelisted.com \ + -H "Authorization: Token " + ``` + + === "Python 3" + + ``` python + import requests + + URL = 'http://pi.hole:8080/admin/api/whitelist/exact/' + 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** ``` 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 " ``` @@ -203,11 +286,12 @@ The domain/regex to be removed is specified through the URL (``). ``` python import requests - URL = 'http://pi.hole:8080/admin/api/whitelist/exact/whitelisted.com' + URL = 'http://pi.hole:8080/admin/api/whitelist/exact/' 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 (``). import requests import urllib - regex = urllib.parse.quote("(^|\\.)facebook.com$") URL = 'http://pi.hole:8080/admin/api/whitelist/exact/' TOKEN = '' HEADERS = {'Authorization': f'Token {TOKEN}'} + regex = urllib.parse.quote("(^|\\.)facebook.com$") response = requests.delete(URL + regex, headers=HEADERS) print(response.json())