No special API is required. All can be done with a small script and a desktop file. I messed up with this idea, looked at some URL handlers form AUR and got these two files:
Name=ALPM package URL Handler
Comment=Install ALPM packages with pamac-installer from URL scheme x-alpm-package://packagename
# ALPM package URL handler
Make the script executable and place somewhere in the PATH. Install .desktop file with
desktop-file-install or place it where other .desktop files are. If you want automated installation, write some PKGBUILD and build the package (I haven’t write it).
With these two files I can click a link like this:
<a href="x-alpm-package://mc">Install mc</a>
and it opens dialog window and after confirmation and password prompt installs
mc package. (This forum seems to block unusual hyperlinks, so it won’t work right here.)
P.S. Although this idea of installing packages by one click on a web page is quite easy to implement, its use can cause problems, especially if a user does not keep the system up to date, as have been pointed out. In rolling release distribution model fully automated package installation or system update is not a good practice. Sometimes manual user intervention is critical to keep the system in working condition.