Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pagination and filtering to /events API endpoint #46

Open
alvyynm opened this issue Mar 8, 2024 · 1 comment
Open

Add pagination and filtering to /events API endpoint #46

alvyynm opened this issue Mar 8, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@alvyynm
Copy link
Owner

alvyynm commented Mar 8, 2024

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

@alvyynm alvyynm added the enhancement New feature or request label Mar 8, 2024
@alvyynm alvyynm self-assigned this Mar 8, 2024
@alvyynm
Copy link
Owner Author

alvyynm commented May 27, 2024

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"
        }
    ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant