Latest 1.0.0
License MIT
Platforms ios 9.0, osx 10.11, tvos 9.0, watchos 2.0
Dependencies Alamofire

[![CI Status]( Corlatti/AlamofireRouter.svg?style=flat)]( Corlatti/AlamofireRouter)

AlamofireRouter is a simple Alamofire router. If you need swift 2.3 version, use the 0.1.0 pod version


To run the example project, clone the repo, and run pod install from the Example directory first.


  • iOS 9.0+ / Mac OS X 10.9+ / tvOS 9.0+ / watchOS 2.0+
  • Xcode 8.0+



CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.0.0+ is required to build AlamofireRouter

To integrate AlamofireRouter into your Xcode project using CocoaPods, specify it in your Podfile:

source ''
platform :ios, '9.0'

pod 'AlamofireRouter'

Then, run the following command:

$ pod install


You have to create an enum that conform RouterProtocol, so you need variable router and function URLRequest are mandatories.

In router you have to set your API base URL.

In URLRequest you can create your endpoints by function router.endPoint.

The function router.endPoint has four parameters:

  • path: String the path for the endpoint
  • method: Alamofire.HTTPMethod the method of the request, by default is .get
  • parameters: [String : Any] the parameters if necessary, by default is [ : ]
  • encoding: ParameterEncoding the encoding type, by default is URLEncoding.default
  • headers: [[String: String]] the header parameters if necessary, by default is [[:]]

Create your router API

import AlamofireRouter

enum MyAPI: RouterProtocol { 

    case myRequest(myParameter: String)
    case otherRequest(otherParameter: [String: Any])
    case allPersonalizedRequest(param: String)

    var router: Router { return Router(baseURL: "") }

    public func asURLRequest() throws -> URLRequest {

        switch self {

            case .myRequest(let myParameter):

                return router.endPoint(path: "mypath/(myParameter)")

            case .otherRequest(let otherParameter):

                return router.endPoint(path: "otherPath", method: .post, parameters: otherParameter)

            case .allPersonalizedRequest(let param):

                return router.endPoint(path: "myPath", method: .patch, parameters: ["par" : param], encoding: JSONEncoding.prettyPrinted, headers: [["Content-type": "json"]])




Use it with Alamofire

Alamofire.request(MyAPI.myRequest(myParameter: "aValue")).response { resp in 

    // Do some stuff


Use it with AlamofireUIManager

let netManager = AlamofireUIManager.sharedInstance

netManager.request(MyAPI.myRequest(myParameter: "aValue"), completionHandler: { json in

    // Do some stuff



Alex Corlatti, [email protected]


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

Latest podspec

    "name": "AlamofireRouter",
    "version": "1.0.0",
    "summary": "Simple Alamofire router.",
    "description": "Simple Alamofire router, that permit you to create your API in easy way.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Alex Corlatti": "[email protected]"
    "source": {
        "git": "",
        "tag": "1.0.0"
    "social_media_url": "",
    "platforms": {
        "ios": "9.0",
        "osx": "10.11",
        "tvos": "9.0",
        "watchos": "2.0"
    "source_files": "AlamofireRouter/Classes/**/*",
    "dependencies": {
        "Alamofire": [
            "~> 4.0"
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This