{"id":23641232,"url":"https://github.com/jdisho/tinynetworking","last_synced_at":"2025-08-31T17:32:36.354Z","repository":{"id":55141234,"uuid":"123777259","full_name":"jdisho/TinyNetworking","owner":"jdisho","description":"🌩 Simple HTTP network abstraction layer written in Swift","archived":false,"fork":false,"pushed_at":"2021-01-07T14:10:46.000Z","size":718,"stargazers_count":146,"open_issues_count":7,"forks_count":14,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-12-01T16:47:44.067Z","etag":null,"topics":["cocoapods","networking","swift","urlrequest"],"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/jdisho.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":null,"security":null,"support":null}},"created_at":"2018-03-04T10:16:45.000Z","updated_at":"2024-09-25T19:15:55.000Z","dependencies_parsed_at":"2022-08-14T13:20:10.249Z","dependency_job_id":null,"html_url":"https://github.com/jdisho/TinyNetworking","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdisho%2FTinyNetworking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdisho%2FTinyNetworking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdisho%2FTinyNetworking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdisho%2FTinyNetworking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdisho","download_url":"https://codeload.github.com/jdisho/TinyNetworking/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231610640,"owners_count":18400207,"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":["cocoapods","networking","swift","urlrequest"],"created_at":"2024-12-28T09:58:04.449Z","updated_at":"2024-12-28T09:58:04.991Z","avatar_url":"https://github.com/jdisho.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🌩 TinyNetworking\n\u003cp align=\"left\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Swift-5.1-orange.svg\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/platforms-iOS | macOS | watchOS | tvOS-brightgreen.svg?style=flat\" alt=\"Mac\" /\u003e\n    \u003ca href=\"https://twitter.com/_disho\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/twitter-@_disho-blue.svg?style=flat\" alt=\"Twitter: @_disho\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n- A simple network abstraction layer written in Swift.\n- A thin wrapper around NSURLSession.\n- Supports CRUD methods.\n- Compile-time checking for correct API endpoint accesses.\n- Combine extensions to the API.\n- (Optional) RxSwift extensions to the API.\n- Inspired by [Moya](https://github.com/Moya/Moya).\n- No external dependencies. \n\n## 🛠 Installation\n\n### CocoaPods\nTo integrate TinyNetworking into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\npod 'TinyNetworking'\n    \n#or\n    \npod 'TinyNetworking/RxSwift' # for the RxSwift extentions\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n### Carthage \n*Coming Soon*\n\n### Swift Package Manager \nAdd the following as a dependency to your `Package.swift`:\n\n `.package(url: \"https://github.com/jdisho/TinyNetworking.git\", .upToNextMajor(from: \"4.0.0\"))`\n\n### Manually\nIf you prefer not to use any of the dependency managers, you can integrate TinyNetworking into your project manually, by downloading the source code and placing the files on your project directory.\n\n## 🏃‍♀️ Getting started\nSet up an `enum` with all of your API resources like the following:\n\n```swift\nenum Unsplash {\n  case me\n  case photo(id: String)\n  case collection(id: String)\n  case likePhoto(id: String)\n  ...\n}\n```\n\nExtend `enum` and confom to `Resource` protocol.\n\n```swift\nextension Unsplash: Resource {\n  var baseURL: URL {\n    return URL(string: \"https://api.unsplash.com\")!\n  }\n  \n  var endpoint: Endpoint {\n    switch self {\n    case .me:\n      return .get(path: \"/me\")\n    case let .photo(id: id):\n      return .get(path: \"/photos/\\(id)\")\n    case let .collection(id: id):\n      return .get(path: \"/collections/\\(id)\")\n    case let .likePhoto(id: id):\n      return .post(path: \"/photos/\\(id)/like\")\n    }\n  }\n \n  var task: Task {\n    var params: [String: Any] = [:]\n    return .requestWithParameters(params, encoding: URLEncoding())\n  }\n  \n  var headers: [String: String] {\n    return [\"Authorization\": \"Bearer xxx\"]\n  }\n  \n  var cachePolicy: URLRequest.CachePolicy {\n    return .useProtocolCachePolicy\n  }\n}\n```\n\n### ⚙️ Making and handling a request\n```swift\nimport TinyNetworking\n\nlet tinyNetworking = TinyNetworking\u003cUnsplash\u003e()\n\ntinyNetworking.request(.photo(id: \"1234\")) { result in\n  switch result {\n    case let .success(response):\n      let photo = try? response.map(to: Photo.self)\n      print(photo)\n    case let .failure(error):\n      print(error)\n  }\n}\n```\n\n### 🔖 Response\nAfter making a request, `TinyNetworking` gives a result back in the form of `Result\u003cResponse, TinyNetworkingError\u003e`, which has two cases to `switch` over. In case of success, a `Response` object is given, otherwise an error.\n\nThe `Response` object gives the possibility to use: \n- Raw data from the request. \n- The `URLRequest` object.\n- The HTTP response.\n- Debug description. \n- The JSON repdesentation of the data.\n- The pretty printed version of the data in a JSON format.\n- Method to map/decode the data to a decodable object. A decodable object, is an object that conforms to `Codable` (`Decodable+Encodable`) protocol.\n\n\n## 🐍 Reactive Extensions\nReactive extensions are cool. TinyNetworking provides reactive extensions for Combine, RxSwift and **soon** for ReactiveSwift.\n\n### Combine \n```swift \nreturn tinyNetworking\n     .requestPublisher(resource: .photo(id: id))\n     .map(to: Photo.self)\n```\n\n### RxSwift\n```swift\nreturn tinyNetworking.rx\n     .request(resource: .photo(id: id))\n     .map(to: Photo.self)\n```\n## ✨ Example\nSee [Papr](https://github.com/jdisho/Papr/tree/papr-tinyNetworking-version)\n\n## 👤 Author\nThis tiny library is created with ❤️ by [Joan Disho](https://twitter.com/_disho) at [QuickBird Studios](www.quickbirdstudios.com)\n\n### 📃 License\nTinyNetworking is released under an MIT license. See [License.md](https://github.com/jdisho/TinyNetworking/blob/master/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdisho%2Ftinynetworking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdisho%2Ftinynetworking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdisho%2Ftinynetworking/lists"}