{"id":15293516,"url":"https://github.com/chaoscoder/convapi","last_synced_at":"2025-08-08T20:18:07.410Z","repository":{"id":55119308,"uuid":"129618978","full_name":"ChaosCoder/ConvAPI","owner":"ChaosCoder","description":"ConvAPI allows easy HTTP requests in Swift against REST-style APIs with JSON formatting by supporting codable bodies and promised responses.","archived":false,"fork":false,"pushed_at":"2024-01-28T12:08:03.000Z","size":118,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-26T12:44:17.780Z","etag":null,"topics":["json-api","swift"],"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/ChaosCoder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-04-15T14:37:36.000Z","updated_at":"2024-10-29T00:02:31.000Z","dependencies_parsed_at":"2024-03-10T22:28:51.344Z","dependency_job_id":"6e8f7897-b880-466a-a0c7-025882c5825a","html_url":"https://github.com/ChaosCoder/ConvAPI","commit_stats":{"total_commits":44,"total_committers":3,"mean_commits":"14.666666666666666","dds":0.06818181818181823,"last_synced_commit":"393db513ea0f37a06568723396da9ada41f95714"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/ChaosCoder/ConvAPI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChaosCoder%2FConvAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChaosCoder%2FConvAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChaosCoder%2FConvAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChaosCoder%2FConvAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChaosCoder","download_url":"https://codeload.github.com/ChaosCoder/ConvAPI/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChaosCoder%2FConvAPI/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269482592,"owners_count":24424403,"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-08T02:00:09.200Z","response_time":72,"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":["json-api","swift"],"created_at":"2024-09-30T16:49:50.466Z","updated_at":"2025-08-08T20:18:07.393Z","avatar_url":"https://github.com/ChaosCoder.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ConvAPI \n[![](http://img.shields.io/badge/Swift-5.0-blue.svg)]() [![](http://img.shields.io/badge/iOS-15.0%2B-blue.svg)]() [![](https://img.shields.io/github/license/ChaosCoder/ConvAPI.svg)](LICENSE.md) [![Build Status](https://app.bitrise.io/app/9bd0d2e769e903f9/status.svg?token=9IwhtVc_5lq3l5PnCY9LLQ\u0026branch=master)](https://app.bitrise.io/app/9bd0d2e769e903f9)\n\nConvAPI allows easy [HTTP](https://tools.ietf.org/html/rfc7231) requests in [Swift](https://swift.org) against [REST](https://en.wikipedia.org/wiki/Representational_state_transfer)-style [APIs](https://en.wikipedia.org/wiki/Application_programming_interface) with [JSON](https://www.json.org/) formatting by supporting [codable](https://developer.apple.com/documentation/swift/codable) bodies and [promised](https://github.com/mxcl/PromiseKit) responses.\n\n## Etymology\nConvAPI (`/kənˈveɪ-piː-aɪ/`) is a contraction of **Convey** (*to carry, bring, or take from one place to another*) and **API** (*Application Programming Interface*).\n\n## Usage\n\nConvAPI has the method\n```swift\nfunc request\u003cT, U, E\u003e(method: APIMethod,\n                      baseURL: URL,\n                      resource: String,\n                      headers: [String: String]?,\n                      params: [String: Any]?,\n                      body: T?,\n                      error: E.Type,\n                      decorator: ((inout URLRequest) -\u003e Void)?) async throws -\u003e U\n```\nwhere `T: Encodable, U: Decodable, E: (Error \u0026 Decodable)` at its core.\n\nThis method allows you to asynchronously request a resource from an API specifying the \n- method (*e.g. `GET`*),\n- baseURL,\n- resource URI (*e.g. `/users/42`*),\n- http headers as a dictionary, \n- query params as a dictionary, \n- request body (any type that conforms to `Encodable`),\n- an error struct (`Decodable`) your API might respond with and,\n- a decorator to access/alter the `URLRequest` that gets fired underneath\n\nand getting the response with a type (`U`) conforming to `Decodable`. All of the error handling (*status code, empty response, etc.*) and parsing is done for you.\n\n### Requesting a resource\n\nRequest a resource by specifying \n\n```swift\nstruct User: Codable {\n    let id: Int\n    let name: String\n}\n        \nlet api = ConvAPI()\nlet baseURL = URL(string: \"https://jsonplaceholder.typicode.com\")!\nlet user: User = try await api.request(method: .GET, baseURL: baseURL, resource: \"/users/1\", error: ConvAPIError.self)\nprint(user) // User(id: 1, name: \"Leanne Graham\")\n```\n\n### Specifying an error\n\nIf your API has an error JSON it is responsing with, just define your error response and hand it in:\n\n```swift\nstruct MyAPIError: Error, Codable {\n    let code: Int\n    let message: String\n}\n\ndo {\n    let user: User = try await api.request(method: .GET, baseURL: baseURL, resource: \"/users/1\", error: MyAPIError.self)\n    // [...]\n} catch {\n    switch error {\n        case let error as MyAPIError: print(error.code)\n        default: break // Request error, network down, etc.\n    }\n}\n```\n\n### Swift Package Manager\n\n```swift\n.package(url: \"https://github.com/ChaosCoder/ConvAPI.git\", from: \"1.0.0\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchaoscoder%2Fconvapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchaoscoder%2Fconvapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchaoscoder%2Fconvapi/lists"}