Today we will learn how to hook up any application you’ve built with NoCode-X with an external source through API’s. For the sake of this tutorial we will integrate a NoCode-X application with a Baserow database. We will create a set of actions that can be used across your application and will allow you to access your database without constantly repeating the technical details of accessing an API.
Baserow is an open-source no-code database tool that allows users to create and manage databases without the need for extensive coding or technical expertise. It provides a user-friendly interface for creating custom database applications and is designed to simplify the process of working with data.
First thing we should do is create an account at baserow.io and create a database and an API key, start with this quickstart when you are not familiar with baserow. For this tutorial we’ve created a simple table: “Employees” with 2 fields: firstname and lastname and added some initial data to it:
Every database in baserow comes with an API which we can call to retrieve data from it or upload data towards it. That’s exactly what we will do. You can view generated API docs for your database by clicking on the three dots next to your company and then clicking on “API Docs”
On this page you get an explanation on how to access your API. For example an endpoint we can use to fetch a list of data from your table is:
https://api.baserow.io/api/database/rows/table/{{TABLE_ID}}/?user_field_names=true
We also see that we have some parameters we can add for further filtering. Lets head over to NoCode-X and make it call this endpoint. First thing to do is store our API key in a safe space. We can leverage the data-classification system in NoCode-X to store our API key safely which will automatically encrypt this value and keep an audit trail of every read/write access.
Once we have this in place, lets make a piece of data using this data-format containing our API key.
{
"apikey": "<<YOUR API KEY>>"
}
Okay, now that we have our API key safely stored in our database we can instruct NoCode-X on how to make a call to our baserow API. Lets make an action and provide it with enough parameters making it reusable for other baserow tables/databases.
Voila, we have our action, now lets build a small page that allows us to easily test this logic.
You can now preview this page by clicking the preview button. Click the “Click here” button and head over to the application logs by using the side navigation to see the results.
The names of our employees appear in the list. So our API Call works! That’s good but it would be great if we were able to reuse this action in the future. That way we would not have to worry about the technical details involved when accessing an API. Lets make our action a bit more reusable. Lets start by adding some parameters to filter our requests: tableId, page, size.
Okay, we’ve created our parameters now lets use them. The tableId is a part of the url we need to call so lets construct the url before we execute the API Call. We can do this by using the “Replace placeholders” function. This will allow us to change the value “https://api.baserow.io/api/database/rows/table/{{TABLE_ID}}/?user_field_names=true” to “https://api.baserow.io/api/database/rows/table/171741/?user_field_names=true” for example.
Now use this URL from the variable scope as the endpoint to call in the “API Call” block:
Now lets use the page & size parameters we defined on our action. The baserow API allows you to pass in query parameters with your call. We can pass in the “page” parameter to filter which page we want to fetch and we can pass in “size” to filter how many items we should fetch per page. We can just “translate” the parameters we defined in our action to the query parameters baserow expects. Lets do this by creating an “Object” and passing that object as the “Query parameters” of our API call.
Now all we have to do is use the variable “QUERYPARAMETERS” in our API Call.
Okay, this is a little more reusable and flexible. Lets create a small action where we execute our “Query baserow datalist” action and provide it with some values for the parameters we have created.
As you can see, you now get the first 3 results back from your database. That’s great, we can now tweak the values of the parameters to get other results. However, the result of this query is not available in “My test action”, it is available in “Query baserow datalist” obviously because that’s where we write the results to the logs. Within NoCode-X every action can have several “Output” values. These values will then be placed on the variable scope of the calling action making them available to use within that action. You can easily define those “Output” values, lets do it for “Query baserow datalist“.
The “Output” values work by searching the variable scope for variables that have the same name as the “Output” values at the end of executing an action. When these variables are found they are placed on the variable scope of the calling action. Thus we need to make sure that there are variables in the variable scope of “Query baserow datalist” with the names “RESULT” and “COUNT”.
Baserow answers API calls by giving a somewhat standard response. They include: count, next, previous & a list of results in their RESPONSE. Lets create a data-format resembling their response making it possible for us to reason with in our actions.
This tells our editor that the response of this API call is formatted accourding to the Dat-format we’ve created. Now we can reason with the response from baserow in our action. Lets use this to set the necessary values in our scope so they can be picked up as “Output”. We can use 2 functions for this “Store number in scope” and “Store list in scope”. Lets add them to our action.
Lets use this in “My test action” by writing out the count in the application logs and by looping over the results, writing the firstname of the employee in the application logs. We can use the Function “For each” to do so. But first we must create another “Data-Format” this one will be used to represent the data that is actually in our baserow database, our employee data.
First we will have to let NoCode-X know under what names the Output data of our “Query baserow datalist” should stored within the Variable scope of our “My Test action”. We can do so by setting the names in the result tab of the “Execute action” block. It is important that we do this, because otherwise collisions with already existing variables could happen. So we have to make sure we let the outputs be written to variables that do not exist yet.
The “For each” function executes an action exactly once for each item of a certain list. So if you have a list of 3 employees for example. This function will execute a certain action 3 times. The item (the employee for example) of current iteration is passed along as the value of a parameter. Of course this parameter has to exist on the action. Lets configure the “For each” block.
Now all that remains is to write the name of our employees in the application log, in the newly created action:
We can see that we have 4 messages in our logs. The total amount of employees in our database followed by the names returned by the baserow api. You can see how you can easily use our “Query baserow datalist” to retrieve data from all your tables within baserow, simply by passing another tableId and by using another data-format.
Just like that we’ve created a nice reusable action that we can use within our application or across applications by publishing it to our private or even public Hub.
Ready for more action? Check out: NoCode-Xpert: Building a reusable REST api call #2 where we will continue our work by adding filter, search & order capabilities!
Interested in all updates to our platform? Subscribe to our newsletter.