Retool Coursera API call

Hi!

I'm encountering an issue when trying to do an API call to coursera to get a full list of learners programs in Retool.


In my response, i can only get 1000 records , but i have more which is 13832. I’m not able to view or access the remaining records, and I haven't been able to find a setting or option to display all records.

Is there a limit in Retool on the number of rows that can be displayed in a table component? If so, is there a way to increase this limit for the API call?

Thanks for your help!

1 Like

Hello @TeeDev and welcome to the community!

It appears that your API is only returning the first 1000 due to paging settings. In your API documentation there should be information about how to handle paging, possibly with a limit parameter during your API call, but more likely you will need to create some looping logic to collect all of your results (if you truly need to return them all at once).

Here is a link to the Coursera Business API page on this topic and how to use their settings: https://dev.coursera.com/docs/coursera-for-business-api-product/1/types/Pagination

1 Like

Let us know if you still need assistance with this, @TeeDev! It looks like most of the Coursera Business API endpoints take limit and offset parameters, which allow you to retrieve specific subsets of your data. If you sent a request with limit equal to 1000 and offset to 1500, for example, the API should return the records from 1500 to 2499.

If you are limited to retrieving 1000 records at a time, which seems to be the case, you'll need to make multiple requests in order to get everything. One option is to do this in a loop, like @pyrrho mentioned. The exact implementation can differ depending on the specifics of your API and query, but below is one example what that might look like in a JS script.

let allData = [];
let limit = 1000;
let offset = 0;
let keepFetching = true;

while (keepFetching) {
    const response = await queryName.trigger({
      additionalScope: { limit , offset }
    });

    allData = allData.concat(data);

    if (data.length < limit) {
        keepFetching = false;
    } else {
        offset += limit;
    }
}

return allData;