ApiKit is a Swift SDK that helps you integrate with external REST APIs.
ApiKit has lightweight ApiEnvironment
and ApiRoute
protocols that make it easy to model any REST-based API. It also has an ApiRequest
that can define a route and response type for even easier use.
Once you have an environment and routes, you can use a regular URLSession
or a custom ApiClient
to fetch any route or request from any environment.
ApiKit can be installed with the Swift Package Manager:
https://github.com/danielsaidi/ApiKit.git
You can use ApiEnvironment
s and ApiRoute
s to model any API, and create Codable
models that automatically map response data from the API.
Once you have created your API-specific types, you can use a plain URLSession
or any custom ApiClient
to fetch data.
let client = URLSession.shared
let environment = YelpEnvironment.v3(apiToken: "TOKEN")
let route = YelpRoute.restaurant(id: "abc123")
let restaurant: YelpRestaurant = try await client.fetchItem(at: route, in: environment)
For more information, please see the getting started guide.
The online documentation has more information, articles, code examples, etc.
The demo app lets you explore the library on iOS and macOS. To try it out, just open and run the Demo
project.
You can sponsor me on GitHub Sponsors or reach out for paid support, to help support my open-source projects.
Your support makes it possible for me to put more work into these projects and make them the best they can be.
Feel free to reach out if you have questions or want to contribute in any way:
- Website: danielsaidi.com
- Mastodon: @danielsaidi@mastodon.social
- Twitter: @danielsaidi
- E-mail: daniel.saidi@gmail.com
ApiKit is available under the MIT license. See the LICENSE file for more info.