Assistance with API calls

Hello

  1. Pagination Handling in Retool:

I tried to utilize pagination for data retrieval through RestAPI calls. To optimize this process, is there a built-in functionality within Retool to seamlessly receive all pages of data automatically, avoiding the need for iterative page calls?

  1. Nested JSON Data Reformatting:

Some API returns JSON data in a specific format with nested structures. I'm curious if Retool provides any native functionality to streamline the reformatting of nested JSON data, as in the example provided below:

(Original Format)

{
  "accruedMillis": %%(color:rgb(211, 99, 99);)0%!,
  "areas": [
    {
      "id": %%(color:rgb(211, 99, 99);)0%!,
      "name": %%(color:rgb(162, 252, 162);)"string"%!,
      "type": %%(color:rgb(162, 252, 162);)"string"%!
    }
  ],
  "assignedAt": %%(color:rgb(162, 252, 162);)"2024-01-10T01:50:56.445Z"%!,
  "assignedTo": [
    {
      "id": %%(color:rgb(211, 99, 99);)0%!,
      "name": %%(color:rgb(162, 252, 162);)"string"%!,
      "type": %%(color:rgb(162, 252, 162);)"string"%!
    }
  ],
  "categories": [
    {
      "id": %%(color:rgb(211, 99, 99);)0%!,
      "name": %%(color:rgb(162, 252, 162);)"string"%!,
      "type": %%(color:rgb(162, 252, 162);)"string"%!
    }
  ],
  "children": [
    {
      "id": %%(color:rgb(211, 99, 99);)0%!,
      "name": %%(color:rgb(162, 252, 162);)"string"%!
    }
}

(Desired Reformatted Format)

{
  "address": %%(color:rgb(162, 252, 162);)"string"%!,
  "city": %%(color:rgb(162, 252, 162);)"string"%!,
  "company": %%(color:rgb(162, 252, 162);)"string"%!,
  "country": %%(color:rgb(162, 252, 162);)"st"%!,
  "dateFormat": %%(color:rgb(162, 252, 162);)"string"%!,
  "email": %%(color:rgb(162, 252, 162);)"string"%!,
  "firstName": %%(color:rgb(162, 252, 162);)"string"%!,
  "id": %%(color:rgb(211, 99, 99);)0%!,
  "language": %%(color:rgb(162, 252, 162);)"st"%!,
  "lastLoginDate": %%(color:rgb(162, 252, 162);)"2024-01-10T01:45:03.871Z"%!,
  "lastName": %%(color:rgb(162, 252, 162);)"string"%!,
  "name": %%(color:rgb(162, 252, 162);)"string"%!,
  "phone": %%(color:rgb(162, 252, 162);)"string"%!,
  "registryDate": %%(color:rgb(162, 252, 162);)"2024-01-10T01:45:03.871Z"%!,
  "skills": %%(color:rgb(162, 252, 162);)"string"%!,
  "state": %%(color:rgb(162, 252, 162);)"string"%!,
  "status": %%(color:rgb(162, 252, 162);)"ACTIVATED"%!,
  "timeZone": %%(color:rgb(162, 252, 162);)"America/New_York"%!,
  "title": %%(color:rgb(162, 252, 162);)"string"%!,
  "zip": %%(color:rgb(162, 252, 162);)"string"%!
}

While it seems possible to achieve this through JSON string parsing and code, I am seeking clarification if Retool offers an alternative method for this specific task.

Your insights and guidance on these matters are immensely appreciated.

Hi @an.dima, welcome to the forum! :wave:

We can decide if we would like server or client side pagination for any of our tables. To enable client side pagination, select it as an add-on on the Table Component settings:


By default, the "Add-on" should pop up as "Client-side." If your table already shows "Server-side" pagination, clicking on the "Add-on" will open a new settings page on the inspector where you can disable server-side pagination.

This setting page will open when clicking on the "Add-on":


Client side pagination will reduce the amount of times you call on the API but it may slow things down a bit if the response has a lot of data.

For the reformatting nested JSON Data, there is no native functionality in Retool that can do it with one click. But here is a doc to learn about JavaScript Transformers. They are useful to format data using JS.

Let us know if you have any questions! :slightly_smiling_face: