{"repo":"davidcelis/api-pagination","free":true,"listed":false,"github":"https://github.com/davidcelis/api-pagination","clone":"git clone https://github.com/davidcelis/api-pagination.git","description":":page_facing_up: Link header pagination for Rails and Grape APIs.","language":"Ruby","stars":689,"topics":["ruby","api","pagination","rails","grape","kaminari","willpaginate"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"api-pagination Paginate in your headers, not in your response body. This follows the proposed RFC-8288 standard for Web linking. Installation In your Gemfile : Configuration (optional) By default, api-pagination will detect whether you're using Pagy, Kaminari, or WillPaginate, and it will name headers appropriately. If you want to change any of the configurable settings, you may do so: Pagy-specific configuration Pagy does not have a built-in way to specify a maximum number of items per page, but api-pagination will check if you've set a :max per page variable. To configure this, you can use the following code somewhere in an initializer: If left unconfigured, clients can request as many items per page as they wish, so it's highly recommended that you configure this. Rails In your controller, provide a pageable collection to the paginate method. In its most convenient form, paginate simply mimics render : This will pull your collection from the json or xml option, paginate it for you using params[:page] and params[:per page] , render Link headers, and call ActionController::Base#render with whatever you passed to paginate . This should work well with ActiveModel::Serializers. However, if you need more control over what is done with your paginated collection, you can pass the collection directly to paginate to receive a paginated collection and have your headers set. Then, you can pass that paginated collection to a serializer or do whatever you want with it: Note that the col","default_branch":null,"files":null,"tree":[],"storefront":"/r/davidcelis","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/davidcelis/api-pagination/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}