Open alvyynm opened 6 months ago
Can use implementation similar to https://reqres.in/ where you pass the number of items per page and the page number as url query params like so:
https://reqres.in/api/users?page=2&per_page=3
This means the API should be able to specify the current page number, number of items per page, total items, and total pages: Sample:
{
"page": 2,
"per_page": 3,
"total": 12,
"total_pages": 4,
"data": [
{
"id": 4,
"email": "eve.holt@reqres.in",
"first_name": "Eve",
"last_name": "Holt",
"avatar": "https://reqres.in/img/faces/4-image.jpg"
},
{
"id": 5,
"email": "charles.morris@reqres.in",
"first_name": "Charles",
"last_name": "Morris",
"avatar": "https://reqres.in/img/faces/5-image.jpg"
},
{
"id": 6,
"email": "tracey.ramos@reqres.in",
"first_name": "Tracey",
"last_name": "Ramos",
"avatar": "https://reqres.in/img/faces/6-image.jpg"
}
]
}
Current Situation
Right now, sending a GET
/events
returns the list of all events in the db. This is inefficient when the list grows.Solution
Add pagination to
/events
allowing consumers to receive event data in chunks