Falcon: Does falcon support pagination?

Created on 10 Sep 2018  路  3Comments  路  Source: falconry/falcon

Hi,
I need to paginate on response if a GET request.
However, I didn't find any option for pagination.
Could anyone help?
Thanks

Most helpful comment

Hi @hadiasheri !
Strictly speaking, responses cannot be paginated per se, data sets can.

However, Falcon is a fairly minimalist WSGI framework, which is not tied to a single data source or a database library.
There are actually some higher level frameworks that build upon Falcon trying exactly that:
https://github.com/falconry/falcon/wiki/Higher-Level-Frameworks
How does your project look like? Maybe some of these frameworks could fit your case? For instance, Peach from the list above does support pagination, others probably too (I have admittedly not checked all of them thoroughly).

Otherwise, if you are using SQLAlchemy, most of the work could be done by paginating data in the database (see, for instance, https://github.com/wizeline/sqlalchemy-pagination ). Falcon has a quick FAQ on using SQLAlchemy (https://falcon.readthedocs.io/en/stable/user/faq.html?highlight=database#how-do-i-manage-my-database-connections), as well as a very simplistic example project (https://github.com/jmvrbanac/falcon-example). I will ask its author if we could add pagination to that example.

Hope anything of the above helps.

Kindly,
Vytas

All 3 comments

Hi @hadiasheri !
Strictly speaking, responses cannot be paginated per se, data sets can.

However, Falcon is a fairly minimalist WSGI framework, which is not tied to a single data source or a database library.
There are actually some higher level frameworks that build upon Falcon trying exactly that:
https://github.com/falconry/falcon/wiki/Higher-Level-Frameworks
How does your project look like? Maybe some of these frameworks could fit your case? For instance, Peach from the list above does support pagination, others probably too (I have admittedly not checked all of them thoroughly).

Otherwise, if you are using SQLAlchemy, most of the work could be done by paginating data in the database (see, for instance, https://github.com/wizeline/sqlalchemy-pagination ). Falcon has a quick FAQ on using SQLAlchemy (https://falcon.readthedocs.io/en/stable/user/faq.html?highlight=database#how-do-i-manage-my-database-connections), as well as a very simplistic example project (https://github.com/jmvrbanac/falcon-example). I will ask its author if we could add pagination to that example.

Hope anything of the above helps.

Kindly,
Vytas

Thanks a lot @vytas7.
I will try your great recommendations.

Closing this hoping you found or crafted an acceptable solution, and the feature request in falcon-example remains, but do not hesitate to reopen or create a new issue should you need further help on this!

Was this page helpful?
0 / 5 - 0 ratings