{"id":24801594,"url":"https://github.com/futuredapp/ftapikit","last_synced_at":"2025-10-13T03:30:29.121Z","repository":{"id":42444002,"uuid":"149443392","full_name":"futuredapp/FTAPIKit","owner":"futuredapp","description":"Declarative and generic REST API framework using Codable.","archived":false,"fork":false,"pushed_at":"2024-04-05T13:07:37.000Z","size":1245,"stargazers_count":20,"open_issues_count":7,"forks_count":3,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-01-09T09:34:35.816Z","etag":null,"topics":["api-client","codable","declarative","functional","protocol","rest-api","urlsession"],"latest_commit_sha":null,"homepage":"","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/futuredapp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-09-19T11:56:06.000Z","updated_at":"2024-11-27T20:12:12.000Z","dependencies_parsed_at":"2024-04-04T13:58:59.881Z","dependency_job_id":"048d643d-04f7-463a-a136-d33f9f741ef4","html_url":"https://github.com/futuredapp/FTAPIKit","commit_stats":{"total_commits":359,"total_committers":16,"mean_commits":22.4375,"dds":0.4317548746518106,"last_synced_commit":"46528ab76ca3ead8bdc32fb96f8591f7bf6d2748"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futuredapp%2FFTAPIKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futuredapp%2FFTAPIKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futuredapp%2FFTAPIKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/futuredapp%2FFTAPIKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/futuredapp","download_url":"https://codeload.github.com/futuredapp/FTAPIKit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236298292,"owners_count":19126500,"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","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":["api-client","codable","declarative","functional","protocol","rest-api","urlsession"],"created_at":"2025-01-30T04:29:23.407Z","updated_at":"2025-10-13T03:30:23.792Z","avatar_url":"https://github.com/futuredapp.png","language":"Swift","readme":"\u003cimg align=\"right\" alt=\"FTAPIKit logo\" src=\"Sources/FTAPIKit/Documentation.docc/Resources/FTAPIKit.svg\"\u003e\n\n# FTAPIKit\n\n![Cocoapods](https://img.shields.io/cocoapods/v/FTAPIKit)\n![Cocoapods platforms](https://img.shields.io/cocoapods/p/FTAPIKit)\n![License](https://img.shields.io/cocoapods/l/FTAPIKit)\n\n![macOS 11](https://github.com/futuredapp/FTAPIKit/actions/workflows/macos-11.yml/badge.svg?branch=main)\n![macOS 10.15](https://github.com/futuredapp/FTAPIKit/actions/workflows/macos-10.15.yml/badge.svg?branch=main)\n![Ubuntu](https://github.com/futuredapp/FTAPIKit/actions/workflows/ubuntu-latest.yml/badge.svg?branch=main)\n\nDeclarative and generic REST API framework using Codable.\nWith standard implementation using URLSesssion and JSON encoder/decoder.\nEasily extensible for your asynchronous framework or networking stack.\n\n## Installation\n\nWhen using Swift package manager install using Xcode 11+\nor add following line to your dependencies:\n\n```swift\n.package(url: \"https://github.com/futuredapp/FTAPIKit.git\", from: \"1.5.0\")\n```\n\nWhen using CocoaPods add following line to your `Podfile`:\n\n```ruby\npod 'FTAPIKit', '~\u003e 1.5'\n```\n\n## Features\n\nThe main feature of this library is to provide documentation-like API\nfor defining web services. This is achieved using declarative\nand protocol-oriented programming in Swift.\n\nThe framework provides two core protocols reflecting the physical infrastructure:\n\n- `Server` protocol defining single web service.\n- `Endpoint` protocol defining access points for resources.\n\nCombining instances of type conforming to `Server` and `Endpoint` we can build request.\n`URLServer` has convenience method for calling endpoints using `URLSession`.\nIf some advanced features are required then we recommend implementing API client.\nThis client should encapsulate logic which is not provided by this framework\n(like signing authorized endpoints or conforming to `URLSessionDelegate`).\n\n![Architecture](Sources/FTAPIKit/Documentation.docc/Resources/Architecture.png)\n\nThis package contains predefined `Endpoint` protocols.\nUse cases like multipart upload, automatic encoding/decoding\nare separated in various protocols for convenience.\n\n- `Endpoint` protocol has empty body. Typically used in `GET` endpoints.\n- `DataEndpoint` sends provided data in body.\n- `UploadEndpoint` uploads file using `InputStream`.\n- `MultipartEndpoint` combines body parts into `InputStream` and sends them to server.\n  Body parts are represented by `MultipartBodyPart` struct and provided to the endpoint\n  in an array.\n- `RequestEndpoint` has encodable request which is encoded using encoding\n  of the `Server` instance.\n\n![Endpoint types](Sources/FTAPIKit/Documentation.docc/Resources/Endpoints.svg)\n\n## Usage\n\n### Defining web service (server)\n\nFirstly we need to define our server. Structs are preferred but not required:\n\n```swift\nstruct HTTPBinServer: URLServer {\n    let baseUri = URL(string: \"http://httpbin.org/\")!\n    let urlSession = URLSession(configuration: .default)\n}\n```\n\nIf we want to use custom formatting we just need to add our encoding/decoding configuration:\n\n```swift\nstruct HTTPBinServer: URLServer {\n    ...\n\n    let decoding: Decoding = JSONDecoding { decoder in\n        decoder.keyDecodingStrategy = .convertFromSnakeCase\n    }\n    let encoding: Encoding = JSONEncoding { encoder in\n        encoder.keyEncodingStrategy = .convertToSnakeCase\n    }\n}\n```\n\nIf we need to create specific request, add some headers, usually to provide\nauthorization we can override default request building mechanism.\n\n```swift\nstruct HTTPBinServer: URLServer {\n    ...\n    func buildRequest(endpoint: Endpoint) throws -\u003e URLRequest {\n        var request = try buildStandardRequest(endpoint: endpoint)\n        request.addValue(\"MyApp/1.0.0\", forHTTPHeaderField: \"User-Agent\")\n        return request\n    }\n}\n```\n\n### Defining endpoints\n\nMost basic `GET` endpoint can be implemented using `Endpoint` protocol,\nall default propertires are inferred.\n\n```swift\nstruct GetEndpoint: Endpoint {\n    let path = \"get\"\n}\n```\n\nLet's take more complicated example like updating some model.\nWe need to supply encodable request and decodable response.\n\n```swift\nstruct UpdateUserEndpoint: RequestResponseEndpoint {\n    typealias Response = User\n\n    let request: User\n    let path = \"user\"\n}\n```\n\n### Executing the request\n\nWhen we have server and enpoint defined we can call the web service:\n\n```swift\nlet server = HTTPBinServer()\nlet endpoint = UpdateUserEndpoint(request: user)\nserver.call(response: endpoint) { result in\n    switch result {\n    case .success(let updatedUser):\n        ...\n    case .failure(let error):\n        ...\n    }\n}\n```\n\n## Contributors\n\nCurrent maintainer and main contributor is [Matěj Kašpar Jirásek](https://github.com/mkj-is), \u003cmatej.jirasek@futured.app\u003e.\n\nWe want to thank other contributors, namely:\n\n- [Mikoláš Stuchlík](https://github.com/mikolasstuchlik)\n- [Radek Doležal](https://github.com/eRDe33)\n- [Adam Bezák](https://github.com/bezoadam)\n- [Patrik Potoček](https://github.com/Patrez)\n\n## License\n\nFTAPIKit is available under the MIT license. See the [LICENSE file](LICENSE) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuturedapp%2Fftapikit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuturedapp%2Fftapikit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuturedapp%2Fftapikit/lists"}