Ajax is generally used to call a file from a specific URL with some parameters.
You could use this method to make a working API, but it would require to create a processing method in the background for example with a PHP/MySql server.
The other more obvious approach would be to build your own plugin for it.
This way the plugin could be shared or sold so others would be able to use the api as well.