Is there an API command to disable ad blocking?

I’d like to be able to create a bookmark in a browser that will turn off blocking for 5 minutes, just by clicking on the bookmark, with no password authentication. Is this possible? Ideally there would be a token in the bookmark. This could also be controlled with a service like IFTTT.com

1 Like

There is no way to do it without authentication. You will need to have this as your bookmark:
http://pi.hole/admin/api.php?disable&auth=PWHASH

Where PWHASH is the value of WEBPASSWORD in /etc/pihole/setupVars.conf
You can also replace disable with enable to enable Pi-hole.

3 Likes

Is there a way to disable it for only 5 minutes?

1 Like

If you set the disable parameter to a number, it will disable it for that many seconds.
http://pi.hole/admin/api.php?disable=300&auth=PWHASH

2 Likes

This should be in the FAQ. Diabling ad blocking for a short period is extremely useful.

1 Like

tada! It is now an FAQ :tada:

3 Likes

A post was split to a new topic: Generate Disable API URL from Web Interface

Thank you for posting this information in the FAQ. I just found out about it this morning!

Currently this is a bookmark on my wife's phone's homepage where she can disable adblock for her mobile games. I set it up with curl because I plan to do more with it later this weekend. If you wish to use the script you'll need to install php-curl and reboot the webservice or device.

Thanks again Mcat12 for posting this information and FutureTense for requesting it.

<?php
// create in /var/www/html/<pagename>.php
$PWHASH = rtrim(shell_exec('grep -oPi "(?<=WEBPASSWORD\=).+" /etc/pihole/setupVars.conf'));

$localhost = rtrim(shell_exec('grep -oPi "(?<=IPV4_ADDRESS\=).+" /etc/pihole/setupVars.conf | egrep -o "^[^\/]+"'));

$ch = curl_init("http://${localhost}/admin/api.php?disable=300&auth=${PWHASH}");

$data = curl_exec($ch);
curl_close($ch);
?>

Use this with caution.

Hello,
because I don't use the dhcp function of Pi-Hole I tried this URL:

http://192.168.1.37/admin/api.php?disable=10&auth=MYPASSWORD

Unfortunatly it doesn't work.
With MYPASSWORD I can login into Pi-Hole.

What I'm doing wrong?

Thanks in advance.

If I read the above postings the correct command is

http://pi.hole/admin/api.php?disable=300&auth=PWHASH

So don't use your login password but

Where PWHASH is the value of WEBPASSWORD in /etc/pihole/setupVars.conf

1 Like

Yes you're totally right.
I was wondering if I should see any changes here when executing the Url-command.