{"id":19390773,"url":"https://github.com/einstore/githubkit","last_synced_at":"2025-04-24T00:31:32.155Z","repository":{"id":48536213,"uuid":"191404130","full_name":"Einstore/GitHubKit","owner":"Einstore","description":"GitHub API client written in Swift with the help of Apple NIO","archived":false,"fork":false,"pushed_at":"2021-07-21T05:39:53.000Z","size":67,"stargazers_count":17,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T22:51:14.322Z","etag":null,"topics":["github","github-api","nio2","swift"],"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/Einstore.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":"2019-06-11T15:51:26.000Z","updated_at":"2024-12-23T22:14:16.000Z","dependencies_parsed_at":"2022-08-12T19:50:53.702Z","dependency_job_id":null,"html_url":"https://github.com/Einstore/GitHubKit","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Einstore%2FGitHubKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Einstore%2FGitHubKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Einstore%2FGitHubKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Einstore%2FGitHubKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Einstore","download_url":"https://codeload.github.com/Einstore/GitHubKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250539431,"owners_count":21447307,"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":["github","github-api","nio2","swift"],"created_at":"2024-11-10T10:23:16.149Z","updated_at":"2025-04-24T00:31:30.869Z","avatar_url":"https://github.com/Einstore.png","language":"Swift","readme":"# GitHubKit\n\n[![Slack](https://img.shields.io/badge/join-slack-745EAF.svg?style=flat)](https://bit.ly/2UkyFO8)\n[![iOS](https://img.shields.io/badge/iOS-ff0000.svg?style=flat)](https://github.com/Einstore/Einstore)\n[![macOS](https://img.shields.io/badge/macOS-ff0000.svg?style=flat)](https://github.com/Einstore/Einstore)\n[![Ubuntu](https://img.shields.io/badge/Ubuntu-D95E33.svg?style=flat)](https://www.ubuntu.com/download/server)\n[![Swift 5.1](https://img.shields.io/badge/swift-5.1-orange.svg?style=flat)](http://swift.org)\n[![Vapor 4](https://img.shields.io/badge/vapor-4.0-blue.svg?style=flat)](https://vapor.codes)\n\nSuper simple to use Github API client library written using Apple NIO\n\n## Functionality\n\nThe below probably don't contain all methods from the spec but it's a good start ...\n\n- [x] Organizations\n- [x] Repos\n- [x] Files\n- [x] File contents\n- [x] Comments\n- [x] Commits (full management)\n- [x] Branches\n- [x] Webhooks\n- [x] Tags\n- [x] Releases\n- [ ] PR's\n- [ ] Issues\n\n## Usage\n\n#### Add to your Package.swift file\n\n```swift\n.package(url: \"https://github.com/Einstore/GitHubKit.git\", from: \"1.0.0\")\n```\n\nDon't forget about your target\n\n```swift\n.target(\n    name: \"App\",\n    x: [\n        \"GitHubKit\"\n    ]\n)\n```\n\n#### Configure\n```swift\nlet config = Github.Config(\n    username: \"orafaj\",\n    token: token,\n    server: \"https://github.ford.com/api/v3/\"\n)\nlet github = try Github(config)\n\n// or\n\nlet github = try Github(config, eventLoop: eventLoop)\n\n// or \n\nlet github = try Github(config, eventLoopGroupProvider: .createNew)\n```\n\n#### Use in iOS and server side frameworks\n\nAlthough this library has been only tested with Vapor 4, using Apple NIO HHTPClient should be compatible with any iOS or server side project.\n\nPlease let us know on our [slack here](https://bit.ly/2UkyFO8) how you getting on or should you need any support!\n\n#### Use in Vapor 4?\n\n```swift\nimport GitHubKit\n\n// In configure.swift\nservices.register(Github.self) { container in\n    let config = Github.Config(\n        username: \"orafaj\",\n        token: token,\n        server: \"https://github.ford.com/api/v3/\"\n    )\n    return try Github(config, eventLoop: container.eventLoop)\n}\n\n// In routes (or a controller)\nr.get(\"github\", \"organizations\") { req -\u003e EventLoopFuture\u003c[Organization]\u003e in\n    let github = try c.make(Github.self)\n    return try Organization.query(on: github).getAll().map() { orgs in\n        print(orgs)\n        return orgs\n    }\n}\n```\n\n## Development\n\nAdding a new API call is ... surprisingly super simple too\n\nLets say you need to add a detail of a user\n\n#### Go to the documentation\n\nhttps://developer.github.com/v3/users/\n\n#### Autogenerate a model\n\nCopy the example JSON, for example:\n\n```json\n{\n  \"login\": \"octocat\",\n  \"id\": 1,\n  \"node_id\": \"MDQ6VXNlcjE=\",\n  \"avatar_url\": \"https://github.com/images/error/octocat_happy.gif\",\n  \"gravatar_id\": \"\",\n  \"url\": \"https://api.github.com/users/octocat\",\n  \"html_url\": \"https://github.com/octocat\",\n  \"followers_url\": \"https://api.github.com/users/octocat/followers\",\n  \"following_url\": \"https://api.github.com/users/octocat/following{/other_user}\",\n  \"gists_url\": \"https://api.github.com/users/octocat/gists{/gist_id}\",\n  \"starred_url\": \"https://api.github.com/users/octocat/starred{/owner}{/repo}\",\n  \"subscriptions_url\": \"https://api.github.com/users/octocat/subscriptions\",\n  \"organizations_url\": \"https://api.github.com/users/octocat/orgs\",\n  \"repos_url\": \"https://api.github.com/users/octocat/repos\",\n  \"events_url\": \"https://api.github.com/users/octocat/events{/privacy}\",\n  \"received_events_url\": \"https://api.github.com/users/octocat/received_events\",\n  \"type\": \"User\",\n  \"site_admin\": false,\n  \"name\": \"monalisa octocat\",\n  \"company\": \"GitHub\",\n  \"blog\": \"https://github.com/blog\",\n  \"location\": \"San Francisco\",\n  \"email\": \"octocat@github.com\",\n  \"hireable\": false,\n  \"bio\": \"There once was...\",\n  \"public_repos\": 2,\n  \"public_gists\": 1,\n  \"followers\": 20,\n  \"following\": 0,\n  \"created_at\": \"2008-01-14T04:33:35Z\",\n  \"updated_at\": \"2008-01-14T04:33:35Z\"\n}\n```\n\nGo to the https://app.quicktype.io and convert the JSON into a model ... you might want to mess a bit with the settings to keep the models consistent with ones in the project already. Also, any sub structs (unless they can be used elsewhere) should be moved inside of the parent model. \n\nOh yeah ... and call the main class `User`! :) ...\n\nImport `Vapor` and conform the main model to `Content` instead of `Codable`.\n\n#### Make a request extension\n\nFirst you need to conform the `User` model to `Queryable`. This will enable the `User.query(on: container)` method.\n\n```swift\nextension User: Queryable { }\n```\n\nNext we create an extension on `QueryableProperty` which is generated each time you request a query on a container from the previous step. Make sure you specify the `QueryableType == User`\n\n```swift\nextension QueryableProperty where QueryableType == User {\n    \n    /// Get all organizations for authenticated user\n    public func get() throws -\u003e EventLoopFuture\u003cUser\u003e {\n        return try github.get(path: \"user\")\n    }\n    \n}\n```\n\n#### All done\n\nYou should be able to call `try User.query(on: c).get()` and get an `EventLoopFuture\u003cUser\u003e` with the details of your authenticated user.\n\n### Author\n\n**Ondrej Rafaj** @rafiki270\n\n(It wasn't my token after all, was it?!)\n\n### License\n\nMIT; See LICENSE file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feinstore%2Fgithubkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feinstore%2Fgithubkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feinstore%2Fgithubkit/lists"}