{"id":1641,"url":"https://github.com/Restofire/Restofire","last_synced_at":"2025-08-02T04:32:08.184Z","repository":{"id":3768928,"uuid":"44917568","full_name":"Restofire/Restofire","owner":"Restofire","description":"Restofire is a protocol oriented networking client for Alamofire","archived":true,"fork":false,"pushed_at":"2022-04-28T22:05:42.000Z","size":2843,"stargazers_count":379,"open_issues_count":6,"forks_count":26,"subscribers_count":9,"default_branch":"develop","last_synced_at":"2025-07-20T18:42:28.315Z","etag":null,"topics":["alamofire","carthage","cocoapods","moya","networking","protocol-oriented","protocol-oriented-programming","restofire","swift","urlsession","xcode"],"latest_commit_sha":null,"homepage":"https://restofire.github.io/Restofire/","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Restofire.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-25T16:08:52.000Z","updated_at":"2024-10-17T02:23:46.000Z","dependencies_parsed_at":"2022-11-28T10:33:56.526Z","dependency_job_id":null,"html_url":"https://github.com/Restofire/Restofire","commit_stats":null,"previous_names":["rahulkatariya/reactofire"],"tags_count":34,"template":false,"template_full_name":null,"purl":"pkg:github/Restofire/Restofire","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Restofire%2FRestofire","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Restofire%2FRestofire/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Restofire%2FRestofire/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Restofire%2FRestofire/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Restofire","download_url":"https://codeload.github.com/Restofire/Restofire/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Restofire%2FRestofire/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268334615,"owners_count":24233793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alamofire","carthage","cocoapods","moya","networking","protocol-oriented","protocol-oriented-programming","restofire","swift","urlsession","xcode"],"created_at":"2024-01-05T20:15:52.092Z","updated_at":"2025-08-02T04:32:07.891Z","avatar_url":"https://github.com/Restofire.png","language":"Swift","funding_links":[],"categories":["Networking","HarmonyOS","Network"],"sub_categories":["Video","Other free courses","Windows Manager"],"readme":"## ![Restofire: A Protocol Oriented Networking Abstraction Layer in Swift](https://raw.githubusercontent.com/Restofire/Restofire/master/Assets/restofire.png)\n\n[![Platforms](https://img.shields.io/cocoapods/p/Restofire.svg)](https://cocoapods.org/pods/Restofire)\n[![License](https://img.shields.io/cocoapods/l/Restofire.svg)](https://raw.githubusercontent.com/Restofire/Restofire/master/LICENSE)\n\n[![Swift Package Manager](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![CocoaPods compatible](https://img.shields.io/cocoapods/v/Restofire.svg)](https://cocoapods.org/pods/Restofire)\n\n[![Travis](https://img.shields.io/travis/Restofire/Restofire/master.svg)](https://travis-ci.org/Restofire/Restofire/branches)\n\n[![Join the chat at https://gitter.im/Restofire/Restofire](https://badges.gitter.im/Restofire/Restofire.svg)](https://gitter.im/Restofire/Restofire?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n[![Twitter](https://img.shields.io/twitter/follow/rahulkatariya91.svg?style=social\u0026label=Follow)](https://twitter.com/rahulkatariya91)\n\nRestofire is a protocol oriented networking client for [Alamofire](https://github.com/Alamofire/Alamofire).\n\n- [Features](#features)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Usage](#usage)\n- [License](#license)\n\n## Features\n\n- [x] Global Configuration for host / headers / parameters etc\n- [x] Group Configurations\n- [x] Per Request Configuration\n- [x] Authentication\n- [x] Response Validations\n- [x] Custom Response Serializers like JSONDecodable\n- [x] Isolate Network Requests from ViewControllers\n- [x] Auto retry based on URLError codes\n- [x] Request eventually when network is reachable\n- [x] NSOperations\n\n## Requirements\n\n- iOS 10.0+ / Mac OS X 10.12+ / tvOS 10.0+ / watchOS 3.0+\n- Xcode 10\n\n## Installation\n\n### Dependency Managers\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cstrong\u003eCocoaPods\u003c/strong\u003e\u003c/summary\u003e\n\n[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:\n\n```bash\n$ gem install cocoapods\n```\n\nTo integrate Restofire into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '10.0'\nuse_frameworks!\n\npod 'Restofire', '~\u003e 5.0'\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cstrong\u003eCarthage\u003c/strong\u003e\u003c/summary\u003e\n\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.\n\nYou can install Carthage with [Homebrew](http://brew.sh/) using the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate Restofire into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"Restofire/Restofire\" ~\u003e 5.0\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cstrong\u003eSwift Package Manager\u003c/strong\u003e\u003c/summary\u003e\n\nTo use Restofire as a [Swift Package Manager](https://swift.org/package-manager/) package just add the following in your Package.swift file.\n\n```swift\nimport PackageDescription\n\nlet package = Package(\n    name: \"HelloRestofire\",\n    dependencies: [\n        .Package(url: \"https://github.com/Restofire/Restofire.git\", from: \"5.0.0\")\n    ]\n)\n```\n\n\u003c/details\u003e\n\n### Manually\n\nIf you prefer not to use either of the aforementioned dependency managers, you can integrate Restofire into your project manually.\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cstrong\u003eGit Submodules\u003c/strong\u003e\u003c/summary\u003e\u003cp\u003e\n\n- Open up Terminal, `cd` into your top-level project directory, and run the following command \"if\" your project is not initialized as a git repository:\n\n```bash\n$ git init\n```\n\n- Add Restofire as a git [submodule](http://git-scm.com/docs/git-submodule) by running the following command:\n\n```bash\n$ git submodule add https://github.com/Restofire/Restofire.git\n$ git submodule update --init --recursive\n```\n\n- Open the new `Restofire` folder, and drag the `Restofire.xcodeproj` into the Project Navigator of your application's Xcode project.\n\n  \u003e It should appear nested underneath your application's blue project icon. Whether it is above or below all the other Xcode groups does not matter.\n\n- Select the `Restofire.xcodeproj` in the Project Navigator and verify the deployment target matches that of your application target.\n- Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the \"Targets\" heading in the sidebar.\n- In the tab bar at the top of that window, open the \"General\" panel.\n- Click on the `+` button under the \"Embedded Binaries\" section.\n- You will see two different `Restofire.xcodeproj` folders each with two different versions of the `Restofire.framework` nested inside a `Products` folder.\n\n  \u003e It does not matter which `Products` folder you choose from.\n\n- Select the `Restofire.framework` \u0026 `Alamofire.framework`.\n\n- And that's it!\n\n\u003e The `Restofire.framework` is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.\n\n\u003c/p\u003e\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cstrong\u003eEmbeded Binaries\u003c/strong\u003e\u003c/summary\u003e\u003cp\u003e\n\n- Download the latest release from https://github.com/Restofire/Restofire/releases\n- Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the \"Targets\" heading in the sidebar.\n- In the tab bar at the top of that window, open the \"General\" panel.\n- Click on the `+` button under the \"Embedded Binaries\" section.\n- Add the downloaded `Restofire.framework` \u0026 `Alamofire.framework`.\n- And that's it!\n\n\u003c/p\u003e\u003c/details\u003e\n\n### Configurations\n\n#### Three levels of configuration\n\n- **Global Configuration** – The global configuration will be applied to all the requests. These include values like scheme, host, version, headers, sessionManager, callbackQueue, maxRetryCount, waitsForConnectivity etc.\n\n```swift\nfunc application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -\u003e Bool {\n\n    Restofire.Configuration.default.host = \"httpbin.org\"\n    Restofire.Retry.default.retryErrorCodes = [.requestTimedOut,.networkConnectionLost]\n\n    return true\n}\n```\n\n- **Group Configuration** – The group configuration inherits all the values from the global configuration. It can be used to group requests that have same behaviour but are different from the global configuration. For instance, If you have more than one host or if your global configuration has default url session and some requests require you to use ephemeral URL session.\n\n```swift\nimport Restofire\n\nprotocol ApiaryConfigurable: Configurable {}\n\nextension ApiaryConfigurable {\n    public var configuration: Configuration {\n        var configuration = Configuration.default\n        configuration.host = \"private-07c21-rahulkatariya.apiary-mock.com\"\n        configuration.headers = [\"Content-Type\": \"application/json\"]\n        return configuration\n    }\n}\n\nprotocol ApiaryRequestable: Requestable, ApiaryConfigurable {}\n\nimport Restofire\n\nstruct NoteResponseModel: Decodable {\n    var id: Int16\n    var title: String\n}\n\nstruct NotesGETService: ApiaryRequestable {\n    typealias Response = [NoteResponseModel]\n    var path: String? = \"notes\"\n}\n```\n\n- **Per Request Configuration** – The request configuration inherits all the values from the group configuration or directly from the global configuration.\n\n```swift\nimport Restofire\n\nstruct NoteRequestModel: Encodable {\n    var title: String\n}\n\nstruct NotePOSTService: Requestable {\n    typealias Response = NoteResponseModel\n    let host: String = \"private-07c21-rahulkatariya.apiary-mock.com\"\n    let headers = [\"Content-Type\": \"application/json\"]\n    let path: String? = \"notes\"\n    let method: HTTPMethod = .post\n    var parameters: Any?\n\n    init(parameters: NoteRequestModel) {\n        let data = try! JSONEncoder().encode(parameters)\n        self.parameters = try! JSONSerialization.jsonObject(with: data, options: .allowFragments)\n    }\n}\n```\n\n## Usage\n\n### Making a Request\n\n`Requestable` gives completion handler to enable making requests and receive response.\n\n```swift\nimport Restofire\n\nclass ViewController: UITableViewController {\n    var notes: [NoteResponseModel]!\n    var requestOp: RequestOperation\u003cNotesGetAllService\u003e!\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n        // We want to cancel the request to save resources when the user pops the view controller.\n        requestOp = NotesGetAllService().execute() {\n            if let value = $0.result.value {\n                self.notes = value\n            }\n        }\n    }\n\n    func postNote(title: String) {\n        let noteRequestModel = NoteRequestModel(title: title)\n        // We don't want to cancel the request even if user pops the view controller.\n        NotePOSTService(parameters: noteRequestModel).execute()\n    }\n\n    deinit {\n        requestOp.cancel()\n    }\n}\n```\n\n### Isolating Network Requests from UIViewControllers\n\n`Requestable` gives delegate methods to enable making requests from anywhere which you can use to store data in your cache.\n\n```swift\nimport Restofire\n\nstruct NotesGetAllService: ApiaryRequestable {\n    ...\n\n    func request(_ request: RequestOperation\u003cNotesGetAllService\u003e, didCompleteWithValue value: [NoteResponseModel]) {\n      // Here you can store the results into your cache and then listen for changes inside your view controller.\n    }\n}\n```\n\n### Custom Response Serializers\n\n- **Decodable**\n\nBy adding the following snippet in your project, All `Requestable` associatedType Response as `Decodable` will be decoded with JSONDecoder.\n\n```swift\nimport Restofire\n\nextension Restofire.DataResponseSerializable where Response: Decodable {\n    public var responseSerializer: DataResponseSerializer\u003cResponse\u003e {\n        return DataRequest.JSONDecodableResponseSerializer()\n    }\n}\n```\n\n- **JSON**\n\nBy adding the following snippet in your project, All `Requestable` associatedType Response as `Any` will be decoded with NSJSONSerialization.\n\n```swift\nimport Restofire\n\nextension Restofire.DataResponseSerializable where Response == Any {\n    public var responseSerializer: DataResponseSerializer\u003cResponse\u003e {\n        return DataRequest.jsonResponseSerializer()\n    }\n}\n```\n\n### Wait for Internet Connectivity\n\n`Requestable` gives you a property waitsForConnectivity which can be set to true. This will make the first request regardless of the internet connectivity. If the request fails due to .notConnectedToInternet, it will retry the request when internet connection is established.\n\n```swift\nstruct PushTokenPutService: Requestable {\n\n    typealias Response = Data\n    ...\n    var waitsForConnectivity: Bool = true\n\n}\n```\n\n# Contributing\n\nIssues and pull requests are welcome!\n\n# Author\n\nRahul Katariya [@rahulkatariya91](https://twitter.com/rahulkatariya91)\n\n## License\n\nRestofire is released under the MIT license. See [LICENSE](https://github.com/Restofire/Restofire/blob/master/LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRestofire%2FRestofire","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRestofire%2FRestofire","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRestofire%2FRestofire/lists"}