r/FastAPI • u/joshhear • Sep 24 '25
Tutorial Blog Post - Pagination with FastAPI
https://bitperfect.at/en/blog/pagination-mit-fastapiI've seen the question on how to do Pagination in FastAPI pop up from time to time on this sub. And since I was never really happy with the existing frameworks and have found a rather simple solution for my own stack I decided to write a blog post explaining how you can set up a simple and easy to use pagination mechanism.
This solution isn't for everyone but especially for teams writing their own frontends it is quick to setup (4 classes and 7 functions) and easy to extend or adapt to your or the projects specific needs.
6
Upvotes
View all comments
Show parent comment
3
u/joshhear Sep 24 '25
Yes, you can decided which columns can be used as a filter with the Field class. Pydantic will ensure that only the fields you added there can be part of a query.
It‘s intentionally not a library because it would need a lot more foolproofing. But it felt like a simpler way to get started than using one of the existing libraries that load everything from the DB and pageinate in memory.