Skip to content

Pagination

Why pagination?

When you're making calls to the API, there will often be a lot of results to return. For this reason, results are paginated to make sure responses are more performant and easier to handle.

Let's say your initial call is asking for all the share classes; the result could be a large response with thousands of records. That's not a good place to start.

A limit of 100 results is applied by default, but we recommend you always explicitly set the page_size parameter to ensure you know how many results per page you receive.

Pagination settings

Let's try an example. Say you need to request all Fund records from your Fundipedia instance, but you only want the results 50 at a time. The endpoint we're going to execute to specifically get the paged records is /api/fund?page=1&page_size=50, with the page being the starting point (one is the first page) and page_size being the number of records to return.

The GET request would look something like this:

curl -X GET "https://demo.api.fundipedia.com/api/fund?page=1&page_size=50" -H  "accept: application/json"

In the response note the pagination details returned: 

  "page": 1,
  "page_size": 100,
  "size": 100,
  "total_pages": 7,
  "links": {
    "next": "/?page=2&page_size=100",
    "prev": null
  }
The  links  collection indicates what API call you can make to either request the next set of results or the previous. Note above there is no  prev  link in the response, meaning there's no results before this page.

How do I know if there are more pages?

When the response doesn't contain a link to the next page of results, you know that you've reached the end. Below you'll see the call for the next page of results, and the response which doesn't contain a next link.

https://demo.api.fundipedia.com/api/fund?page=7&page_size=100
  "page": 7,
  "page_size": 100,
  "size": 32,
  "total_pages": 7,
  "links": {
    "next": null,
    "prev": "/?page=6&page_size=100"
  }





Feedback and Knowledge Base