{"id":16699857,"url":"https://github.com/malcommac/gitlabswift","last_synced_at":"2025-06-27T10:36:31.562Z","repository":{"id":89462193,"uuid":"605178725","full_name":"malcommac/GitLabSwift","owner":"malcommac","description":"🛵 Async/Await GitLab REST APIs v4 for Swift","archived":false,"fork":false,"pushed_at":"2024-06-16T19:32:27.000Z","size":1787,"stargazers_count":20,"open_issues_count":5,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-04T00:03:58.203Z","etag":null,"topics":["api-rest","async-await","gitlab","gitlab-api","swift","swift5"],"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/malcommac.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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,"publiccode":null,"codemeta":null}},"created_at":"2023-02-22T16:01:48.000Z","updated_at":"2025-01-29T18:57:50.000Z","dependencies_parsed_at":"2024-04-27T18:34:13.874Z","dependency_job_id":"e2f51063-9bcc-411d-be2e-8b3ead5ba03c","html_url":"https://github.com/malcommac/GitLabSwift","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/malcommac/GitLabSwift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malcommac%2FGitLabSwift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malcommac%2FGitLabSwift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malcommac%2FGitLabSwift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malcommac%2FGitLabSwift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/malcommac","download_url":"https://codeload.github.com/malcommac/GitLabSwift/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malcommac%2FGitLabSwift/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262240604,"owners_count":23280549,"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":["api-rest","async-await","gitlab","gitlab-api","swift","swift5"],"created_at":"2024-10-12T18:08:22.906Z","updated_at":"2025-06-27T10:36:31.513Z","avatar_url":"https://github.com/malcommac.png","language":"Swift","readme":"\u003cp align=\"center\"\u003e\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"./Documentation/gitlabswift-dark-logo.png\" width=\"350\"\u003e\n  \u003cimg alt=\"logo-library\" src=\"./Documentation/gitlabswift-light-logo.png\" width=\"350\"\u003e\n\u003c/picture\u003e\n\u003c/p\n\n\nGitLabSwift is an async/await client to perform type-safe, multi-thread Swift call to the GitLab API services.  \nIt's effortless to use; below just a few examples:\n\n```swift\n// Configure your APIs service connector\nlet api = GitLab(config: .init(baseURL: \"http://...\", {\n    $0.token = \"\u003cYOUR_PERSONAL_TOKEN\u003e\" // GitLab PAT\n})\n\n// SOME EXAMPLES\n\n// Get your profile\nlet me: GLModel.User = try await gitlab.users.me()\n\n// Get projects\nlet response = try await gitlab.projects.list(options: {\n    $0.orderBy = .id\n    $0.statistics = true\n    $0.sort = .desc\n})\n            \n// List some project's commits\nlet commits =try await gitlab.commits.list(project: anyProjectID, options: {\n    $0.since = Date.oneWeekAgo()\n    $0.until = Date.now\n    $0.includeStats = true\n})\n```\n\nEach API is available inside its namespace. Currently, this library supports:\n- [Avatar](https://docs.gitlab.com/ee/api/avatar.html) - via `.avatar`\n- [Branches](https://docs.gitlab.com/ee/api/branches.html) - via `.branches`\n- [Branches (Protected)](https://docs.gitlab.com/ee/api/protected_branches.html) - via `.protectedBranches`\n- [Commits](https://docs.gitlab.com/ee/api/commits.html) - via `.commits`)\n- [Discussions](https://docs.gitlab.com/ee/api/discussions.html) - via `.discussions`\n- [Epic Issues](https://docs.gitlab.com/ee/api/epic_issues.html) - via `.epicIssues`\n- [Issues](https://docs.gitlab.com/ee/api/issues.html) - via `.issues`\n- [IssuesStatistics](https://docs.gitlab.com/ee/api/issues_statistics.html) - via `.issuesStatistics`\n- [Jobs](https://docs.gitlab.com/ee/api/jobs.html)) - via `.jobs`\n- [Labels (Group)](https://docs.gitlab.com/ee/api/group_labels.html) - via `.groupLabels`\n- [Labels (Project)](https://docs.gitlab.com/ee/api/labels.html#list-labels) - via `.labels`\n- [Merge Requests](https://docs.gitlab.com/ee/api/merge_requests.html) - via `.mergeRequests`\n- [Milestones (Group)](https://docs.gitlab.com/ee/api/group_milestones.html) - via `.milestones`\n- [Milestones (Project)](https://docs.gitlab.com/ee/api/milestones.html) - via `.projectMilestones`\n- [Pipelines](https://docs.gitlab.com/ee/api/pipelines.html) - via `.pipelines`\n- [Projects](https://docs.gitlab.com/ee/api/projects.html)) - via `.projects`\n- [Repositories](https://docs.gitlab.com/ee/api/repositories.html) - via `.repositories`\n- [Repository Files](https://docs.gitlab.com/ee/api/repository_files.html) - via `.repositoryFiles`\n- [Tags](https://docs.gitlab.com/ee/api/tags.html)) - via `.tags`\n- [Users](https://docs.gitlab.com/ee/api/users.html) - via `.users`\n\n\u003e **Note**\n\u003e Not all API endpoints are supported. I tried to implement the most commonly used. Feel free to contribute by opening a new PR.\n\n## Documentation\n\nThe usage of the library is pretty simple.  \nFirst of all, you need to instantiate a new `GLApi` service which is the service used to communicate with your own GitLab instance:\n\n```swift\nlet api = GitLab(config: .init(baseURL: \"http://...\", {\n    $0.token = \"\u003cYOUR_PERSONAL_TOKEN\u003e\"\n})\n```\n\nGitLabSwift supports Personal Access Tokens you can create directly from your GitLab instance profile.  \nOnce ready, each context is reachable by calling `gitlab.\u003ccontext\u003e.\u003capi_call\u003e`.  \n\nEach endpoint is type-safe. When an API supports multiple options, an options callback is used where each parameter is type-safe.  \nFor example:\n\n```swift\nlet response = try await gitlab.milestones.list(project: .id(1097), options: {\n    // Each parameter is type-safe\n    $0.includeParent = true\n    $0.state = .activate\n    $0.search = .beginWith(\"geo\")\n})\n```\n\nEach request return a generic object called `GLResponse`.  \nThis object allows you to identify any metadata of the request:\n\n```swift\nprint(\"There are \\(response.totalItems) in \\(response.totalPages)\"\nprint(\"Now showing \\(response.countItemsPerPage) items per page\")\n```\nYou can also access the underlying data via `response.httpResponse` and the original request via `response.httpRequest`.\n\nSince the result is an async throwing function, if an error occurs, a `GLErrors` is cached.\n\nMost of the time, you're interested in getting the decoded objects. GitLabSwift uses `Codable` and each supported GitLab model is exposed via `GLModel` namespace.  \nYou just need to call `response.decode()` function to get the actual model instance from the response:\n\n```swift\nlet tags: [GLModel.Tag] = try await gitlab.tags.list(\n    project: .id(1097), \n    sort: .asc, \n    search: \"release\"\n).decode()\n// You will get an array of `Tags`!\nfor tag in tags {\n    print(\"- Tag \\(tag.name) from commit \\(tag.commit.id) created on \\(tag.commit.created_at)\")\n}\n```\n\nStarting from a response, you can easily move to the next pages:\n\n```swift\nlet nextPageResponse = try await response.nextPage() // move forward\nlet prevPageResponse = try await response.prevPage() // move backward\nlet next3Pages = try await response.nextPages(3) // get the next 3 pages responses from current page of the response\nlet allRemainingPages = try await response.nextPages() // get all remaining pages\n```\n\u003e **Note**\n\u003e These functions execute multiple async requests and return results at the end. If one of the calls fails, the entire flow fails.\n\n## Requirements\n\nGitLabSwift can be installed on any platform which supports:\n\n- iOS 13+, macOS Catalina+, watchOS 6+, tvOS 13+\n- Xcode 14+ \n- Swift 5.7+  \n\n## Installation\n\n### Swift Package Manager\n\nAdd it as a dependency in a Swift Package, and add it to your Package. Swift:\n\n```swift\ndependencies: [\n  .package(url: \"https://github.com/malcommac/GitLabSwift.git\", from: \"0.9.0\")\n]\n```\n\nAnd add it as a dependency of your target:\n\n```swift\ntargets: [\n  .target(name: \"MyTarget\", dependencies: [\n    .product(name: \"https://github.com/malcommac/GitLabSwift.git\", package: \"GitLabSwift\")\n  ])\n]\n```\n\n## Author\n\nGitLabSwift is currently owned and maintained by Daniele Margutti.\n\n- 🐦 on twitter [@danielemargutti](http://twitter.com/danielemargutti/)).\n- 👩‍💻 on my web site [www.danielemargutti.com](https://www.danielemargutti.com)\n- 💼 on LinkedIn [Daniele Margutti](http://linkedin.com/in/danielemargutti/)\n\n## License\n\nThis software is licensed under MIT License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmalcommac%2Fgitlabswift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmalcommac%2Fgitlabswift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmalcommac%2Fgitlabswift/lists"}