Executing Ninox Scripts Via API

By Adam Davidson, Director of Product Management

Ninox has included a great tool in their API which is the ability to send in scripts in the body of a request that will be executed in the cloud against a database. This opens up a huge range of possibilities if you are integrating a third party app or your own custom software with Ninox, or you would like to run a script on one database from another database in Ninox.

There are two ways to send a script for Ninox to execute. One is by inserting the script as a query parameter in a GET request, and the other is by inserting the script in the body of a POST request. I would recommend the latter method since there isn’t the need to URL encode (replace spaces and other special characters with codes like %20) the script in the body of the request.

To use the POST method, send the script in to

https://api.ninoxdb.de/v1/teams/:teamid/databases/ :databaseid/query

replacing the :teamid and :databaseid with the team and database ids of the database on which you would like to run the script. the body of the request should be a json object with a single property named “query” whose value is the script to be executed. See an example below:

{ “query”: “(select CLIENTS where STATUS = \”active\”).(‘FIRST NAME’ + \” \” + ‘LAST NAME’)”}

This example body would get an array of the full names of each record in the CLIENTS table where the client status is active. Notice the \” is used in place ” to let the json know that the quote is part of this string, and not an instruction to end the string.

Any script that would be run in a global function can be sent in the body, (making sure to escape double quotes with \”). Send the API key in the Authorization Header as “Bearer ” + , and include the ‘Content-Type’ header as ‘application/json’ as in any other Ninox API request and you will be good to go.

Go HERE to see the documentation for the request format and all the other possible Ninox requests.

Go HERE to see how you could send in this request from a Ninox script using the http() method (good for if you would like to run a script on one database from another database).

en_USEN