{"id":15038356,"url":"https://github.com/vapor-community/pagination","last_synced_at":"2025-10-17T16:37:53.833Z","repository":{"id":63921198,"uuid":"128463254","full_name":"vapor-community/pagination","owner":"vapor-community","description":"Simple Vapor 3 Pagination","archived":false,"fork":false,"pushed_at":"2019-02-25T18:53:12.000Z","size":52,"stargazers_count":65,"open_issues_count":6,"forks_count":15,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-06T19:48:49.531Z","etag":null,"topics":["fluent","swift-4","vapor","vapor-3"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/vapor-community.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-06T19:53:29.000Z","updated_at":"2024-12-22T19:07:47.000Z","dependencies_parsed_at":"2023-01-14T14:15:20.180Z","dependency_job_id":null,"html_url":"https://github.com/vapor-community/pagination","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapor-community%2Fpagination","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapor-community%2Fpagination/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapor-community%2Fpagination/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vapor-community%2Fpagination/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vapor-community","download_url":"https://codeload.github.com/vapor-community/pagination/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131466,"owners_count":21052819,"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":["fluent","swift-4","vapor","vapor-3"],"created_at":"2024-09-24T20:38:08.043Z","updated_at":"2025-10-17T16:37:48.801Z","avatar_url":"https://github.com/vapor-community.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Swift](http://img.shields.io/badge/swift-4.1-brightgreen.svg)\n![Vapor](http://img.shields.io/badge/vapor-3.0-brightgreen.svg)\n[![CircleCI](https://circleci.com/gh/vapor-community/pagination.svg?style=svg)](https://circleci.com/gh/vapor-community/pagination)\n\n# Vapor Pagination\n\nPagination is based off of the Fluent 2 pagination system.\n\n## Getting Started\nAdd this to your Package.swift file\n```swift\n.package(url: \"https://github.com/vapor-community/pagination.git\", from: \"1.0.0\")\n```\n\nConform your model to `Paginatable`\n\n```swift\nextension MyModel: Paginatable { }\n```\n\nOnce you have done that, it's as simple as returning your query in paginated format.\n```swift\nfunc test(_ req: Request) throws -\u003e Future\u003cPaginated\u003cMyModel\u003e\u003e {\n    return try MyModel.query(on: req).paginate(for: req)\n}\n```\nEven return items off of the query builder\n```swift\nfunc test(_ req: Request) throws -\u003e Future\u003cPaginated\u003cMyModel\u003e\u003e {\n    return try MyModel.query(on: req).filter(\\MyModel.name == \"Test\").paginate(for: req)\n}\n```\n\nMaking a request with the parameters is easy is appending `?page=` and/or `?per=`\n```curl\ncurl \"http://localhost:8080/api/v1/models?page=1\u0026per=10\"\n```\n\nA response looks like this\n```json\n{\n  \"data\": [{\n    \"updatedAt\": \"2018-03-07T00:00:00Z\",\n    \"createdAt\": \"2018-03-07T00:00:00Z\",\n    \"name\": \"My Test Model\"\n  }],\n  \"page\": {\n    \"position\": {\n      \"current\": 1,\n      \"max\": 1\n    },\n    \"data\": {\n      \"per\": 10,\n      \"total\": 2\n    }\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvapor-community%2Fpagination","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvapor-community%2Fpagination","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvapor-community%2Fpagination/lists"}