Skip to content

Repository files navigation


Get

Platform

A lean Swift web API client built using async/await.

Get provides a clear and convenient API for modeling network requests using Request<Response> type. And its APIClient makes it easy to execute these requests and decode the responses.

// Create a client
letclient=APIClient(baseURL:URL(string:"https://api.github.com"))
// Start sending requests
letuser:User=tryawait client.send(Request(path:"/user")).value
varrequest=Request(path:"/user/emails", method:.post, body:["alex@me.com"])tryawait client.send(request)

The client uses URLSession for networking and provides complete access to all its APIs. It is designed with the "less is more" idea in mind and doesn't introduce any unnecessary abstractions on top of native APIs.

// In addition to `APIClientDelegate`, you can also override any methods
// from `URLSessionDelegate` family of APIs.
letclient=APIClient(baseURL:URL(string:"https://api.github.com")){
$0.sessionDelegate =...}
// You can also provide task-specific delegates and easily change any of
// the `URLRequest` properties before the request is sent.
letdelegate:URLSessionDataDelegate=...letresponse=tryawait client.send(Paths.user.get, delegate: delegate){
$0.cachePolicy =.reloadIgnoringLocalCacheData
}

In addition to sending quick requests, it also supports downloading data to a file, uploading from a file, authentication, auto-retries, logging, and more. It's a kind of code that you would typically write on top of URLSession if you were using it directly.

Sponsor 💖

Support Get on GitHub Sponsors.

Documentation

Learn how to use Get by going through the documentation created using DocC.

To learn more about URLSession, see URL Loading System.

Integrations

Pulse

You can easily add logging to your API client using Pulse. It requests a single line to setup.

letclient=APIClient(baseURL:URL(string:"https://api.github.com")){
$0.sessionDelegate =PulseCore.URLSessionProxyDelegate()}

With Pulse, you can inspect logs directly on your device – and it supports all Apple platforms. And you can share the logs at any time and view them on a big screen using Pulse Pro.

pulse-preview

CreateAPI

With CreateAPI, you can take your backend OpenAPI spec, and generate all of the response entities and even requests for Get APIClient.

generate api.github.yaml --output ./OctoKit --module "OctoKit"

Check out App Store Connect Swift SDK that uses CreateAPI for code generation.

Other Extensions

Get is a lean framework with a lot of flexibility and customization points. It makes it very easy to learn and use, but you'll need to install additional modules for certain features.

Minimum Requirements

GetDateSwiftXcodePlatforms
2.2Apr 13, 20245.814.3iOS 13.0, watchOS 6.0, macOS 10.15, tvOS 13.0, Linux
2.0Jul 26, 20225.513.3iOS 13.0, watchOS 6.0, macOS 10.15, tvOS 13.0, Linux

License

Get is available under the MIT license. See the LICENSE file for more info.

About

Web API client built using async/await

Resources

Stars

992 stars

Watchers

9 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages