It looks like you want an Octave interpreter, which runs Octave script
files. This is easier than an interactive Octave interpreter (like
There is no ready to use API, which will give you the functionality seen
in the examples. You will have to build the infrastructure and the API
around it yourself.
A simple approach would be to save the script file as a new m-file, run
octave on this file and then return the output. But be prepared that
this is not trivial (especially when you want to put this on a public
- How can the backend be secured against malicious script files?
- How to handle long running processes (timeouts, denial of service)?
- How to handle graphics output?
An Octave package which gives you sort of an API ist the cgi package
(https://octave.sourceforge.io/cgi/). It could be used to receive the
script file as a POST parameter from an HTML form, run it with the eval
function, and return the result as plain text.
To protect your backend from malicious scripts, you could run Octave
inside isolated docker containers, but I have no practical experience in