{"id":16685959,"url":"https://github.com/danielsaidi/apikit","last_synced_at":"2025-06-15T12:06:32.069Z","repository":{"id":147935714,"uuid":"618295322","full_name":"danielsaidi/ApiKit","owner":"danielsaidi","description":"ApiKit is a Swift SDK that helps you integrate with any REST API and automatically map responses to Swift models.","archived":false,"fork":false,"pushed_at":"2025-05-09T15:33:07.000Z","size":4802,"stargazers_count":60,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-27T08:52:55.588Z","etag":null,"topics":["api","ios","macos","network","networking","rest","swift","tvos","visionos","watchos"],"latest_commit_sha":null,"homepage":"https://danielsaidi.com/opensource","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/danielsaidi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null},"funding":{"github":["danielsaidi"]}},"created_at":"2023-03-24T06:52:45.000Z","updated_at":"2025-05-09T15:33:11.000Z","dependencies_parsed_at":"2024-01-17T21:56:58.899Z","dependency_job_id":"47af7726-856b-439f-85c6-c62bec3d8edf","html_url":"https://github.com/danielsaidi/ApiKit","commit_stats":{"total_commits":106,"total_committers":3,"mean_commits":"35.333333333333336","dds":"0.018867924528301883","last_synced_commit":"49af4c47d54458b21176148efb870134e8b1ad2e"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/danielsaidi/ApiKit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielsaidi%2FApiKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielsaidi%2FApiKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielsaidi%2FApiKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielsaidi%2FApiKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielsaidi","download_url":"https://codeload.github.com/danielsaidi/ApiKit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielsaidi%2FApiKit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259971377,"owners_count":22940011,"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","ios","macos","network","networking","rest","swift","tvos","visionos","watchos"],"created_at":"2024-10-12T15:04:00.268Z","updated_at":"2025-06-15T12:06:32.049Z","avatar_url":"https://github.com/danielsaidi.png","language":"Swift","funding_links":["https://github.com/sponsors/danielsaidi"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"Resources/Icon.png\" alt=\"Project Icon\" width=\"250\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/v/release/danielsaidi/ApiKit?color=%2300550\u0026sort=semver\" alt=\"Version\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/swift-6.0-orange.svg\" alt=\"Swift 6.0\" /\u003e\n    \u003ca href=\"https://danielsaidi.github.io/ApiKit\"\u003e\u003cimg src=\"https://img.shields.io/badge/documentation-web-blue.svg\" alt=\"Documentation\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/danielsaidi/ApiKit/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/danielsaidi/ApiKit\" alt=\"MIT License\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/sponsors/danielsaidi\"\u003e\u003cimg src=\"https://img.shields.io/badge/sponsor-GitHub-red.svg\" alt=\"Sponsor my work\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\n# ApiKit\n\nApiKit is a Swift library that makes it easy to integrate with any REST API and map its response data to Swift types.\n\nApiKit defines an ``ApiClient`` protocol that can be used to request raw \u0026 typed data from any REST API, as well as ``ApiEnvironment`` and ``ApiRoute`` protocols that make it easy to model environments and routes \n\nThe ``ApiClient`` protocol is already implemented by ``URLSession``, so you can use ``URLSession.shared`` directly.\n\n\n\n## Installation\n\nApiKit can be installed with the Swift Package Manager:\n\n```\nhttps://github.com/danielsaidi/ApiKit.git\n```\n\n\n## Support My Work\n\nYou can [become a sponsor][Sponsors] to help me dedicate more time on my various [open-source tools][OpenSource]. Every contribution, no matter the size, makes a real difference in keeping these tools free and actively developed.\n\n\n\n## Getting Started\n\nConsider that you want to integrate with the Yelp API, which can return restaurants, reviews, etc.\n\nYou would first define the various API environments that you want to integrate with. In this case, let's just integrate with the `v3` environment, which requires an API header token for all requests:\n\n```swift\nimport ApiKit\n\nenum YelpEnvironment: ApiEnvironment {\n\n    case v3(apiToken: String)\n    \n    var url: String {\n        switch self {\n        case .v3: \"https://api.yelp.com/v3/\"\n        }\n    }\n \n    var headers: [String: String]? {\n        switch self {\n        case .v3(let token): [\"Authorization\": \"Bearer \\(token)\"]\n        }\n    }\n}\n```\n\nWe can then define the routes to request from the Yelp API. In this case, let's just fetch a business by unique ID:\n\n```swift\nimport ApiKit\n\nenum YelpRoute: ApiRoute {\n\n    case business(id: String)\n\n    var path: String {\n        switch self {\n        case .business(let id): \"businesses/\\(id)\"\n        }\n    }\n\n    var httpMethod: HttpMethod { .get }\n    var headers: [String: String]? { nil }\n    var formParams: [String: String]? { nil }\n    var postData: Data? { nil }\n    \n    var queryParams: [String: String]? {\n        switch self {\n        case .business: nil\n        }\n    }\n}\n``` \n\nWith an environment and route in place, we can now fetch a `YelpBusiness` with any ``ApiClient`` or ``URLSession``:\n\n```swift\nlet client = URLSession.shared\nlet environment = YelpEnvironment.v3(apiToken: \"YOUR_TOKEN\")\nlet route = YelpRoute.business(id: \"abc123\") \nlet business: YelpBusiness = try await client.request(route, in: environment)\n```\n\nThe generic request functions will automatically map the raw response to the requested type, and throw any error that occurs. There are also non-generic variants if you want to get the raw data or use custom error handling.\n\nSee the online [getting started guide][Getting-Started] for more information.\n\n\n\n## Documentation\n\nThe online [documentation][Documentation] has more information, articles, code examples, etc.\n\n\n\n## Demo Application\n\nThe `Demo` folder has a demo app that lets you explore the library and integrate with a few APIs.\n\n\n\n## Contact\n\nFeel free to reach out if you have questions, or want to contribute in any way:\n\n* Website: [danielsaidi.com][Website]\n* E-mail: [daniel.saidi@gmail.com][Email]\n* Bluesky: [@danielsaidi@bsky.social][Bluesky]\n* Mastodon: [@danielsaidi@mastodon.social][Mastodon]\n\n\n\n## License\n\nApiKit is available under the MIT license. See the [LICENSE][License] file for more info.\n\n\n\n[Email]: mailto:daniel.saidi@gmail.com\n[Website]: https://danielsaidi.com\n[GitHub]: https://github.com/danielsaidi\n[OpenSource]: https://danielsaidi.com/opensource\n[Sponsors]: https://github.com/sponsors/danielsaidi\n\n[Bluesky]: https://bsky.app/profile/danielsaidi.bsky.social\n[Mastodon]: https://mastodon.social/@danielsaidi\n[Twitter]: https://twitter.com/danielsaidi\n\n[Documentation]: https://danielsaidi.github.io/ApiKit\n[Getting-Started]: https://danielsaidi.github.io/ApiKit/documentation/apikit/getting-started\n[License]: https://github.com/danielsaidi/ApiKit/blob/master/LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielsaidi%2Fapikit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielsaidi%2Fapikit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielsaidi%2Fapikit/lists"}