The APIs only have a single interface, and that is HTTP. All the examples are just different ways of making an HTTP request, whether through the curl command or a full-blown language. Hitting this API has only one requirement: something capable of making HTTP requests.
Running the script directly requires a correctly-configured environment for each scripting language you want to support on each device. If a script has additional dependencies or libraries, those must also be installed locally if you want to run the script locally. By putting the script behind an HTTP API, it just needs to be correctly configured once on a single device (the API server), and then the requirement for using the script on all other devices is just plain old HTTP.
Suppose you have five different scripts each written in a different language (because languages have their own strengths and weaknesses). And suppose you need to run all of these scripts on three completely different devices (say, a phone, a laptop, and an Arduino). If you want to run the scripts directly on each device, then you need to set up 5*3=15 runtime environments and make sure they all function correctly (and don't break with updates). To save effort, it might make sense to put these scripts behind an HTTP API, and then just use simple HTTP requests from each device to access all scripts in a uniform manner. Note that in reality, you'll probably want to be targeting much more than three devices, so the savings can stack up quickly.
Running the script directly requires a correctly-configured environment for each scripting language you want to support on each device. If a script has additional dependencies or libraries, those must also be installed locally if you want to run the script locally. By putting the script behind an HTTP API, it just needs to be correctly configured once on a single device (the API server), and then the requirement for using the script on all other devices is just plain old HTTP.
Suppose you have five different scripts each written in a different language (because languages have their own strengths and weaknesses). And suppose you need to run all of these scripts on three completely different devices (say, a phone, a laptop, and an Arduino). If you want to run the scripts directly on each device, then you need to set up 5*3=15 runtime environments and make sure they all function correctly (and don't break with updates). To save effort, it might make sense to put these scripts behind an HTTP API, and then just use simple HTTP requests from each device to access all scripts in a uniform manner. Note that in reality, you'll probably want to be targeting much more than three devices, so the savings can stack up quickly.