How to handle this situation in the Rest Export View as api.

We want to fetch a limit of 20 items in the api and with a load more feature. Currently our api produces hundreds of items.

In the Pager section, I can ofcourse select Paged output, full pager and specifiy Items to display, say 20. But how this works in the api? Since its only displaying 20 items, how does load more feature occur? Thanks!

This is my Pager settings.

Items to display:Full | Paged, 20 items

enter image description here


Simply pass the “page” parameter with the request, like ‘api/foo/bar?page=1’. Views will return the next set of results as you increment the page number. You can do the load more interaction however you want on the front end so long as you specify the page and keep track of total results.

| improve this answer | |
  • Thanks for your quick response. It does works in contents, but doesnt seems to be working when using the api response http://localhost:8080/api?_format=json?page=2 – John Rey Tanquinco Jun 19 '18 at 5:26
  • Something else must be wrong then, we are doing this everywhere on a large site. Ensure full pager is selected. – Kevin Jun 19 '18 at 5:27
  • Also in your URL you have two question marks. After the first question mark, all other query parameters should be apprended with an & ampersand. – Kevin Jun 19 '18 at 5:33
  • How would someone know that there is a next page? I ideally you'll want to have a parameter where it says next-page: api/foo/bar?page=2 – No Sssweat Jun 19 '18 at 5:45
  • 1
    Decoupled front ends can be built and you can pass a total results number in the response so pagers can be constructed based on that. It works for either a load more, infinite scroll, or standard numbered pager. – Kevin Jun 19 '18 at 5:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.