{"id":13878530,"url":"https://github.com/bsm/grape-kaminari","last_synced_at":"2025-04-12T18:52:11.778Z","repository":{"id":12347106,"uuid":"14991060","full_name":"bsm/grape-kaminari","owner":"bsm","description":"kaminari paginator integration for grape API framework","archived":false,"fork":false,"pushed_at":"2024-10-28T18:28:11.000Z","size":89,"stargazers_count":160,"open_issues_count":2,"forks_count":83,"subscribers_count":55,"default_branch":"main","last_synced_at":"2025-04-03T22:07:42.811Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bsm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-12-06T19:12:00.000Z","updated_at":"2024-09-23T17:33:51.000Z","dependencies_parsed_at":"2024-03-15T12:31:46.041Z","dependency_job_id":"23d31f9c-4a8d-46bb-beb4-02286c6c806b","html_url":"https://github.com/bsm/grape-kaminari","commit_stats":null,"previous_names":["monterail/grape-kaminari"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsm%2Fgrape-kaminari","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsm%2Fgrape-kaminari/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsm%2Fgrape-kaminari/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsm%2Fgrape-kaminari/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bsm","download_url":"https://codeload.github.com/bsm/grape-kaminari/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248618229,"owners_count":21134200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T08:01:52.241Z","updated_at":"2025-04-12T18:52:11.733Z","avatar_url":"https://github.com/bsm.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Grape::Kaminari\n\n[![Test](https://github.com/bsm/grape-kaminari/actions/workflows/test.yml/badge.svg)](https://github.com/bsm/grape-kaminari/actions/workflows/test.yml)\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\n[kaminari](https://github.com/kaminari/kaminari) paginator integration for [grape](https://github.com/intridea/grape) API framework.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'grape-kaminari'\n```\n\nAnd then execute:\n\n```\n$ bundle\n```\n\nOr install it yourself as:\n\n```\n$ gem install grape-kaminari\n```\n\n## Usage\n\n```ruby\nclass MyApi \u003c Grape::API\n  # Include Grape::Kaminari module in your api\n  include Grape::Kaminari\n\n  resource :posts do\n    desc 'Return a list of posts.'\n\n    # This will add three optional params: page, per_page, and offset\n    #\n    # You can optionally overwrite the default :per_page setting (10)\n    # and the :max_per_page(false/disabled) setting which will use a validator to\n    # check that per_page is below the given number.\n    #\n    # You can disable the offset parameter from appearing in the API\n    # documentation by setting it to false.\n    #\n    params do\n      use :pagination, per_page: 20, max_per_page: 30, offset: 5\n    end\n    get do\n      posts = Post.where(...)\n\n      # Use `paginate` helper to execute kaminari methods\n      # with arguments automatically passed from params\n      paginate(posts)\n    end\n\n    get do\n      things = ['a', 'standard', 'array', 'of', 'things', '...']\n\n      # Use `Kaminari.paginate_array` method to convert the array\n      # into an object that can be passed to `paginate` helper.\n      paginate(Kaminari.paginate_array(things))\n    end\n  end\nend\n```\n\nNow you can make a HTTP request to your endpoint with the following parameters\n\n- `page`: your current page (default: 1)\n- `per_page`: how many to record in a page (default: 10)\n- `offset`: the offset to start from (default: 0)\n\n```\ncurl -v http://host.dev/api/posts?page=3\u0026offset=10\n```\n\nand the response will be paginated and also will include pagination headers\n\n```\nX-Total: 42\nX-Total-Pages: 5\nX-Page: 3\nX-Per-Page: 10\nX-Next-Page: 4\nX-Prev-Page: 2\nX-Offset: 10\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/bsm/grape-kaminari.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsm%2Fgrape-kaminari","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbsm%2Fgrape-kaminari","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsm%2Fgrape-kaminari/lists"}