Back

[Solved] How to paginate documents using Rest API?

  • 1
  • Self Hosted
  • Databases
  • General
joel
2 Aug, 2023, 15:21

In appwrite version 0 this could be done using

https://domain.com/v1/database/collections/users/documents?limit=100 and then adding &cursor=[id#]

where [id#] is the id number of the record that you are paging after.

In the new version of the app, I am able to get my documents, but I'm only getting 25 results instead of 100 and the cursor no longer works. I've also tried using 'cursorAfter' which also does not seem to work.

What is the new syntax for this to work? (both limit and cursor)

TL;DR
To paginate documents using the Rest API in the new version of the app, you need to use the 'queries' parameter instead of the 'limit' parameter. The new syntax would be: https://domain.com/v1/database/collections/users/documents?&queries[]=limit(100) This will return 100 results instead of the default 25. As for the cursor functionality, it has changed in the new version. Instead of using '&cursor=[id#]', you need to refer to the updated documentation: https://appwrite.io/docs/rest#query Using the 'cursorAfter' parameter, you should be able to achieve
Binyamin
2 Aug, 2023, 15:37

Now you need to use queries Check this: https://appwrite.io/docs/rest#query

joel
2 Aug, 2023, 16:49

Thank you, this helped 🙂

joel
2 Aug, 2023, 16:50

[Solved] How to paginate documents using Rest API?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more