{"id":18418621,"url":"https://github.com/bsm/grape-pagy","last_synced_at":"2025-10-04T08:44:30.077Z","repository":{"id":37819024,"uuid":"302102820","full_name":"bsm/grape-pagy","owner":"bsm","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-02T01:39:33.000Z","size":36,"stargazers_count":10,"open_issues_count":2,"forks_count":10,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-22T19:02:31.930Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","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","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}},"created_at":"2020-10-07T16:54:45.000Z","updated_at":"2024-07-02T12:06:14.000Z","dependencies_parsed_at":"2024-03-15T12:31:20.083Z","dependency_job_id":"2e364cc3-b887-4c36-9926-8e9957e26ebd","html_url":"https://github.com/bsm/grape-pagy","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsm%2Fgrape-pagy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsm%2Fgrape-pagy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsm%2Fgrape-pagy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsm%2Fgrape-pagy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bsm","download_url":"https://codeload.github.com/bsm/grape-pagy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247661670,"owners_count":20975096,"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-11-06T04:14:09.727Z","updated_at":"2025-10-04T08:44:25.040Z","avatar_url":"https://github.com/bsm.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Grape::Pagy\n\n[![Ruby](https://github.com/bsm/grape-pagy/actions/workflows/ruby.yml/badge.svg)](https://github.com/bsm/grape-pagy/actions/workflows/ruby.yml)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n[Pagy](https://github.com/ddnexus/pagy) pagination for [grape](https://github.com/ruby-grape/grape) API framework.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'grape-pagy'\n```\n\nAnd then execute:\n\n```\n$ bundle\n```\n\nOr install it yourself as:\n\n```\n$ gem install grape-pagy\n```\n\n## Usage\n\n```ruby\nclass MyApi \u003c Grape::API\n  # Include helpers in your API.\n  helpers Grape::Pagy::Helpers\n\n  resource :posts do\n    desc 'Return a list of posts.'\n    params do\n      # This will add two optional params: :page and :items.\n      use :pagy\n    end\n    get do\n      posts = Post.all.order(created_at: :desc)\n      pagy(posts)\n    end\n  end\n\n  resource :strings do\n    desc 'Supports arrays as well as relations.'\n    params do\n      # Override defaults by setting Pagy::DEFAULT or by passing options.\n      use :pagy,\n          items_param: :per_page, # Accept per_page=N param to limit items.\n          items: 2,               # If per_page param is blank, default to 2.\n          max_items: 10           # Restrict per_page to maximum 10.\n    end\n    get do\n      words = %w[this is a plain array of words]\n      pagy(words)\n    end\n  end\nend\n```\n\nExample request:\n\n```shell\ncurl -si http://localhost:8080/api/posts?page=3\u0026items=5\n```\n\nThe response will be paginated and also will include the following headers:\n\n```\nCurrent-Page: 3\nPage-Items: 5\nTotal-Count: 22\nTotal-Pages: 5\nLink: \u003chttp://localhost:8080/api/posts?page=1\u0026items=5\u003e; rel=\"first\", \u003chttp://localhost:8080/api/posts?page=4\u0026items=5\u003e; rel=\"next\", \u003chttp://localhost:8080/api/posts?page=2\u0026items=5\u003e; rel=\"prev\", \u003chttp://localhost:8080/api/posts?page=5\u0026items=5\u003e; rel=\"last\"),\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/bsm/grape-pagy.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsm%2Fgrape-pagy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbsm%2Fgrape-pagy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsm%2Fgrape-pagy/lists"}