Enable / Disable lists via API

I could not see this in the API docs. I’d like to be able to enable / disable individual lists via the API as you can in the webUI. This would allow me to keep malware blocklists active but disable adblocking temporarily programmatically.

You can enable and disable lists via the API by using PUT on /lists/{list} to update the current status of a list. You need to update it by sending the new enabled: boolean value.

Quick example to enable and disable a list using curl:

curl -H 'accept: application/json' -H 'sid: you-auth-key=' -X PUT "https://pi.hole:443/api/lists/https%3A%2F%2Fv.firebog.net%2Fhosts%2FEasyprivacy.txt?type=block" -d '{"enabled":false}'

This would disable https://v.firebog.net/hosts/Easyprivacy.txt.

2 Likes

The web interface already uses the API to do that.

The only difference is the web interface function changes all properties (groups, comment, enabled and type) at the same time, but you only need to change enabled.

If you need a command line example, darkexplosiveqwx explained how to it.

1 Like

Thanks for the quick response, it wasn’t clear from looking at the list section of the API docs.