🦉Lightweight, stateless REST network manager over the Codable protocol.

What's New

  • The request parameter serialization was updated to use Alamofire's built-in Encodable based approach.
  • With the new version of Alamofire, the raw response data is validated and an error is raised if it's empty for various status codes. This set of status codes were extended to 200..<300

RestBird 🦉

Codacy Badge Build Status codecov


Lightweight, stateless REST network manager over the Codable protocol built upon Alamofire.

To learn more aboit this library, check out the documentation.


  • iOS 10.0+ / macOS 10.12+
  • XCode 11.4+
  • Swift 5.2+


  • Codable support.
  • PromiseKit wrapper.
  • RxSwift wrapper.
  • Automatic request parameter serialization (Codable?)

Installation Instructions

Swift Package Manager

Add RestBird as a dependency to your project.

.package(url: "", from: "0.5")

Then, simply integrate RestBird with your target.

targets: [
    Target(name: "YourTarget", dependencies: ["RestBird"])


pod 'RestBird'

You can also try it out by running

pod try RestBird


github "halcyonmobile/RestBird"


Steps for setting up the project for development:

  • Clone the repo
  • Generate Xcode project by executing swift package generate-xcodeproj
  • Open project



First you need to create your NetworkClientConfiguration configuration with your custom or one of the provided session manager drivers. We're going to use the AlamofireSessionManager.

struct MainAPIConfiguration: NetworkClientConfiguration {
    let baseUrl = ""
    let sessionManager = AlamofireSessionManager()
    let jsonEncoder = JSONEncoder()
    let jsonDecoder = JSONDecoder()

Now we can pass this configuration to the network client.

let networkClient = NetworkClient(configuration: MainAPIConfiguration())

In order to make requests, a DataRequest object should be defined.

struct SignIn: DataRequest {
    typealias ResponseType = Authentication

    let email: String
    let password: String

    let suffix: String? = API.Path.login
    let method: HTTPMethod = .post
    var parameters: [String : Any]? {
        return [ email, API.Param.password: password]

Now use your network client to execute requests.

let request = SignIn(email: "", password: "123456")
networkClient.execute(request: request, completion: { result: Result<Authentication> in


Middlewares are a powerful way to intercept network requests or react to the response the endpoint returns.

At the moment, middlewares fall under two categories:

  • Pre Middlewares (evaluated before the request is about to be executed)
  • Post Middlewares (evaluated after the request was executed)
struct LoggerMiddleware: PreMiddleware {
    func willPerform(_ request: URLRequest) throws {

struct ErrorMiddleware: PostMiddleware {
    func didPerform(_ request: URLRequest, response: URLResponse, data: Data?) throws {
        if let data = data, let error = ErrorProvider.provide(for: data) {
            throw error

// Register middleware

Meta support

To avoid writing boilerplate code for network classes, we wrote a couple of templates to generate code using Sourcery. Head over to the template repository.

Here's how two requests would look like using the templates:

/// sourcery: Service
protocol PostService {

    /// sourcery: path = /posts/\(id)
    /// sourcery: pathParam = id
    func get(id: String, completion: (result: Result<Post>) -> Void)

    /// sourcery: method = post, path = /posts
    /// sourcery: parameter = post
    /// sourcery: parameter = json
    func save(post: Post, completion: (result: Result<Post>) -> Void)


You can find convenience wrappers for RestBird which are not distributed through the package. This includes a PromiseKit and an RxSwift wrapper.

Check out here.


RestBird is released under the MIT license. See LICENSE for details.

If you use the open-source library in your project, please make sure to credit and backlink to


  • Swift Tools 5.2.0
View More Packages from this Author


Last updated: Thu Apr 04 2024 02:58:04 GMT-0900 (Hawaii-Aleutian Daylight Time)