Read rows with API nextpage

Hello all,

I am using the API to get all the records in a table but I cannot have it at once.
I have links with next page token, … but I cannot see how it is working :frowning:
Someone can explain ?
thanks a lot
Alex

Hi, Alexandre, thanks for reaching out!

Can you provide a bit more context about what the intended outcome is here? Would you also mind sharing your doc with us so we can take a closer look at the issues you’re encountering?

You can do that by going to the Share in the top right-hand corner, clicking the button in the top right (to the left of the “X”), and toggling on Share with Coda Support (the gif below shows how to do this).

Afterward, please send us a link to that doc in your response so one of our awesome Customer Champions can take a look for you! :smiley:

-Genevive

when you are using the API to get rows on a table at the end you have

“href”: “https://coda.io/apis/v1/docs/AbCDeFGH/tables/grid-pqRst-U/rows?limit=20”,
“nextPageToken”: “eyJsaW1pd”,
“nextPageLink”: “https://coda.io/apis/v1/docs/AbCDeFGH/tables/grid-pqRst-U/rows?pageToken=eyJsaW1pd”,
“nextSyncToken”: “eyJsaW1pd”

specific to the request you have done in this case 20 results per page.
I would like to get the page 2 of the result. So I think I need to use the next page token but I do not know how to use it and I did not see it in the documentation.

Hi @Alexandre_Husset! The easiest thing to do would just be to make an HTTP request to the nextPageLink value–that’s a complete URL for the next page of results, that includes the nextPageToken already appended to it. (We provide the nextPageToken as an independent value if you are, for example, using a API library where you just want to pass in the token by itself. But if you are making HTTP requests directly, the intention is to just look at the nextPageLink value and request that exactly as is.)

2 Likes

And you may want page3, 4, n…

Typically I create a loop that continues to fetch new blocks of records until the nextPage no longer appears. With each new page, I simply append the 20-record data blocks to a unified result set.

1 Like

So I do not need to do a get request ?

I am using a component rest api of a no code tool and for it I need to send a rest api request.
If I do not need the rest api I have to find another solution / component.
Is there any ways to fetch other pages using rest api request ?

The nextPageLink is a Rest API URL.

Presumably you started by making a GET request to https://coda.io/apis/v1/docs/AbCDeFGH/tables/grid-pqRst-U/rows?

Then to get the next page of results, you would look at the nextPageLink value from that response, and then make a GET request to that URL, which has the form https://coda.io/apis/v1/docs/AbCDeFGH/tables/grid-pqRst-U/rows?pageToken=eyJsaW1pd. It’s just the same REST API URL that you started with, with a token appended that indicates the next page of results. As Bill mentions, you can continue making more GET requests until there is no nextPageLink value anymore, or you have enough results.

Also FYI you can include the parameter limit=100 in your request URL like:

https://coda.io/apis/v1/docs/AbCDeFGH/tables/grid-pqRst-U/rows?limit=100

upon your first request (and it should be then included in the nextPageLink)

This will allow you to get not 20 but 100 rows per request. I think 100 is the maximum, or was it 200? You can try a larger number — Coda will still limit only to the maximum allowed amount.

Other than that — yes, you’ll still have to run this in a loop and keep requesting pages until there is no more next page. This is called pagination in APIs.