Retrieving larger amounts of data.
Some of Metriport’s endpoints are paginated - they return a limited amount of items each time they are requested. Each request being a single “page”.
In order to have access to all items, after we receive the items for the current page we can request the next page to the API.
Each response includes:
meta
: the information about the response.<items>
: the list of items for the respective request, where items
is named according to the respective
type of data being requested - e.g., patients
, documents
.And meta
contains:
itemsOnPage
: the amount of items on the current page.itemsInTotal
: (optional) the total amount of items in all pages - only available on the first page.nextPage
: (optional) the URL to return the next page; if not present, it means there’s not a next page
prevPage
: (optional) the URL to return the previous page; if not present, it means we’re on the first page.In the example below, we’re loading the first page (there’s no prevPage
), with the default number of items
per page. We can see the total amount of items included (113
).
To get the next page, we can just call the URL on nextPage
. When there’s no nextPage
, it means we’re
on the last one. As simple as that.
Metriport’s pagination is designed to simplify its usage, hiding away the complexity for most situations.
But, it can be customized using these parameters:
count
: the number of items to be included in each page/response, optional. Defaults to 50 items per page.
The maximum number of items per page is 500.fromItem
: the ID of the first item to be included in the current page, optional. If not provided, the
first page will be returned.toItem
: the last item to be included in the current page, optional. If not provided, it will
automatically be calculated based on firstItem
and count
.Only two of the parameters above can be specified for each request.
The SDK includes support for the paginated endpoints in two ways:
Typically, one would use the simpler, dedicated “page” function after obtaining the first page:
Alternatively, one can use the detailed version, providing each individual parameter separately when requesting each page:
Retrieving larger amounts of data.
Some of Metriport’s endpoints are paginated - they return a limited amount of items each time they are requested. Each request being a single “page”.
In order to have access to all items, after we receive the items for the current page we can request the next page to the API.
Each response includes:
meta
: the information about the response.<items>
: the list of items for the respective request, where items
is named according to the respective
type of data being requested - e.g., patients
, documents
.And meta
contains:
itemsOnPage
: the amount of items on the current page.itemsInTotal
: (optional) the total amount of items in all pages - only available on the first page.nextPage
: (optional) the URL to return the next page; if not present, it means there’s not a next page
prevPage
: (optional) the URL to return the previous page; if not present, it means we’re on the first page.In the example below, we’re loading the first page (there’s no prevPage
), with the default number of items
per page. We can see the total amount of items included (113
).
To get the next page, we can just call the URL on nextPage
. When there’s no nextPage
, it means we’re
on the last one. As simple as that.
Metriport’s pagination is designed to simplify its usage, hiding away the complexity for most situations.
But, it can be customized using these parameters:
count
: the number of items to be included in each page/response, optional. Defaults to 50 items per page.
The maximum number of items per page is 500.fromItem
: the ID of the first item to be included in the current page, optional. If not provided, the
first page will be returned.toItem
: the last item to be included in the current page, optional. If not provided, it will
automatically be calculated based on firstItem
and count
.Only two of the parameters above can be specified for each request.
The SDK includes support for the paginated endpoints in two ways:
Typically, one would use the simpler, dedicated “page” function after obtaining the first page:
Alternatively, one can use the detailed version, providing each individual parameter separately when requesting each page: