forked from DMPRoadmap/roadmap
-
Notifications
You must be signed in to change notification settings - Fork 13
API Pagination
Brian Riley edited this page Jul 22, 2021
·
1 revision
By default all of the DMPTool API endpoints that return DMP metadata allow for pagination.
Every JSON response from the API will contain the following information that can be used to help determine whether or not you should make subsequent requests to fetch all of the available records:
- page - identifies the current page of results that you have received
- per_page - identifies how many records are returned per request. The default is 20
- total_items - the total number of records available
Depending on circumstances (e.g. which page you are on and the total number of records available) you may also receive the following:
- prev - the path and query string you should use to fetch the previous page of results
- next - the path and query string you should use to fetch the next page of results
For example:
{
"application": "dmptool",
"source": "GET /api/v2/templates",
"time": "2020-02-07T14:04:01-07:00",
"caller": "my_email OR my_application_name",
"code": 200,
"message": "OK",
"page": 2,
"per_page": 20,
"total_items": 58,
"prev": "/api/v2/templates?page=1&per_page=20",
"next": "/api/v2/templates?page=3&per_page=20",
"items": [
"... Placeholder for 20 DMP template records ..."
]
}
You can specify a different page as well as a different number of records you would like to receive by specifying them in your query (see the examples in the prev
and next
attributes in the JSON above). Note that the maximum number of records per page is 100.