Latest 0.8.3
License MIT
Platforms ios 10.0, requires ARC
Dependencies BrightFutures
Frameworks Foundation

Astral is a minimal HTTP Networking library that aims to simplify an application’s networking layer by abstracting
the steps needed to create a network request into multiple objects.

It aims to shy away from the typical network layer singleton by encapsulating each part of network request as an object.

Astral makes use of the BrightFutures library to flatten the asynchronous calls
associated with networking, making your code base as readable as possible.

Inspired by Soroush Khanlou’s blog post on Protocol Oriented

CI Status


Astral requires iOS 10.0 or higher and Swift 3.x



  1. Add the following to your Podfile:
pod 'Astral'
  1. Integrate your dependencies using frameworks: add use_frameworks! to your Podfile.
  2. Run pod install.


Here’s an example using the Pokemon API and the implementations of RequestBuilder and RequestDispatcher
provided by Astral.

Feel free to build and customize your own implementations. Simply adopt the appropriate protocols.

struct PokeAPIConfiguration: Configuration {

    var scheme: URLScheme {
        return URLScheme.http

    var host: String {
        return ""

    var basePathComponents: [String] {
        return [

    var baseHeaders: [String : Any] {
        return [
            "Content-Type": "application/json"
struct PokemonRequest: Request {

    let id: Int

    var configuration: Configuration {
        return PokeAPIConfiguration()

    var pathComponents: [String] {
        return [    

    var method: HTTPMethod {
        return HTTPMethod.get

    var parameters: [String : Any] {
        return [:]

    var headers: [String : Any] {
        return [:]
let queue: DispatchQueue = DispatchQueue(label: "pokeapi", qos: DispatchQoS.utility, attributes: [DispatchQueue.Attributes.concurrent])

let request: Request = PokemonRequest(id: 1)
let dispatcher: RequestDispatcher = JSONRequestDispatcher(request: request)

    .onSuccess(queue.context) { (response: Response) -> Void in
        // let responseData: Data =
        // Do something with data
        // or
        // let dictionary: [String: Any] = response.json.dictValue
        // Do something with dictionary
    .onFailure(queue.context) { (error: NetworkingError) -> Void in
        // Handle the error
    .onComplete(queue.context) { (result: Result<Data, NetworkingError>) -> Void in
        // Handle the completion of the network request
        // such as clean up of the UI


Julio Alorro


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

Latest podspec

    "name": "Astral",
    "module_name": "Astral",
    "version": "0.8.3",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "summary": "An HTTP networking library that uses protocols and Futures",
    "homepage": "",
    "authors": {
        "Julio Alorro": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.8.3"
    "platforms": {
        "ios": "10.0"
    "source_files": "Sources/**/*.swift",
    "requires_arc": true,
    "frameworks": "Foundation",
    "dependencies": {
        "BrightFutures": []
    "pushed_with_swift_version": "4.0"

Pin It on Pinterest

Share This