This chapter covers
- Designing filters, pagination, and sorting for APIs
- Enhancing the PetSitter OpenAPI definition with these features
As the PetSitter application grows, there will eventually be a lot of jobs posted in the system at the same time. It means that pet sitters will have a hard time going through all the job postings to find those they are interested in. Also, the API response for listing the jobs can get quite large. The PetSitter team realized this during their sprint planning in chapter 16. At that time, they decided to implement filters and pagination to solve the issue. While discussing these we’re also adding a third, related topic: sorting.
Before we start looking at API design, though, let’s make sure we’re on the same page regarding the meanings of the terms filters, pagination, and sorting: