{"id":25084927,"url":"https://github.com/telemtobi/swift-networking","last_synced_at":"2026-03-18T00:02:21.579Z","repository":{"id":237278520,"uuid":"794190114","full_name":"TelemTobi/swift-networking","owner":"TelemTobi","description":"An intuitive Swift networking library for seamless, scalable, and maintainable API integration 🚀","archived":false,"fork":false,"pushed_at":"2026-02-02T16:55:00.000Z","size":136,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-03T06:07:43.511Z","etag":null,"topics":["ios-sdk","networking","swift","swift-package-manager","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/TelemTobi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-04-30T16:20:07.000Z","updated_at":"2026-01-03T12:25:48.000Z","dependencies_parsed_at":"2024-12-20T07:26:50.850Z","dependency_job_id":"5a70a396-c140-4b2b-8e3d-30d2426e202f","html_url":"https://github.com/TelemTobi/swift-networking","commit_stats":null,"previous_names":["telemtobi/flux","telemtobi/swift-networking"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/TelemTobi/swift-networking","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TelemTobi%2Fswift-networking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TelemTobi%2Fswift-networking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TelemTobi%2Fswift-networking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TelemTobi%2Fswift-networking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TelemTobi","download_url":"https://codeload.github.com/TelemTobi/swift-networking/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TelemTobi%2Fswift-networking/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30636653,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T23:56:54.546Z","status":"ssl_error","status_checked_at":"2026-03-17T23:56:28.952Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["ios-sdk","networking","swift","swift-package-manager","urlsession"],"created_at":"2025-02-07T07:19:15.587Z","updated_at":"2026-03-18T00:02:21.564Z","avatar_url":"https://github.com/TelemTobi.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swift Networking\n\nA Swift package that makes network requests easier and more maintainable in your iOS, macOS, and other Apple platform applications. It provides a type-safe, clean API with powerful features like environment switching, request interception, and JSON mapping.\n\n[![Swift](https://img.shields.io/badge/Swift-5.9+-orange.svg)](https://swift.org)\n[![SPM](https://img.shields.io/badge/SPM-Compatible-brightgreen.svg)](https://swift.org/package-manager)\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n\n## Features\n\n- ✨ Type-safe API endpoints using Swift enums\n- 🌍 Built-in environment switching (live, test, preview)\n- 🔒 Powerful request \u0026 response interception\n- 🗺️ Flexible JSON mapping and response processing\n- 🔁 Retry handling with exponential backoff (opt-in per endpoint)\n- 📝 Comprehensive logging for debugging\n- 💪 Full async/await support\n\n## Quick Example\n\nHere's how easy it is to define and use API endpoints with **Networking**:\n\n```swift\nenum MyEndpoint {\n    case getUser(userId: String)\n    case updateProfile(name: String, email: String)\n    case createPost(threadId: String, post: Post)\n}\n\nextension MyEndpoint: Endpoint {\n    var baseURL: URL { URL(string: \"https://your-api.com/api/v1\")! }\n\n    var path: String {\n        switch self {\n        case let .getUser(userId): \"/users/\\(userId)\"\n        case .updateProfile: \"/users/me\"\n        case .createPost: \"/posts\"\n        }\n    }\n\n    var method: HttpMethod {\n        switch self {\n        case .getUser: .get\n        case .updateProfile: .put\n        case .createPost: .post\n        }\n    }\n\n    var task: HttpTask {\n        switch self {\n        case .getUser:\n            return .none\n\n        case let .updateProfile(name, email):\n            return .rawBody([\n                \"user_name\": name,\n                \"email_address\": email\n            ])\n\n        case let .createPost(threadId, post): \n            return .encodableBodyAndQuery(\n                body: post,\n                queryParameters: [\"thread\": threadId]\n            )\n        }\n    }\n}\n\n// Making requests\nlet controller = NetworkingController\u003cMyEndpoint, MyError\u003e()\n\ndo {\n    let user: User = try await controller.request(.getUser(userId: \"123\"))\n    // Handle the user data\n} catch {\n    // Handle MyError\n}\n```\n\n## Installation\n\n### Swift Package Manager\n\nAdd **Networking** to your project via Swift Package Manager:  \n1. In Xcode, go to **File \u003e Swift Packages \u003e Add Package Dependency**.  \n2. Enter the repository URL:\n\n   ```\n   https://github.com/telemtobi/swift-networking.git\n   ```\n\n3. Select your preferred version and finish.\n\n## Usage\n\n### Environment Management\n\nEasily switch between different environments:\n\n```swift\n// Configure with different environments\nlet controller = NetworkingController\u003cMyEndpoint, MyError\u003e(\n    environment: .live    // For production\n    // or .test          // For unit testing\n    // or .preview       // For SwiftUI previews\n)\n\n// Works great with PointFree's Dependencies package\nextension MyApiClient: DependencyKey {\n    static let liveValue = MyApiClient(environment: .live)\n    static let testValue = MyApiClient(environment: .test)\n    static let previewValue = MyApiClient(environment: .preview)\n}\n```\n\n### Request Interception\n\nIntegrate your request interceptor to handle authentication, modify requests/responses, and process errors:\n\n```swift\nclass MyInterceptor: Interceptor {\n    var authenticationState: AuthenticationState { .reachable }\n    \n    func authenticate() async throws -\u003e Bool {\n        // Your authentication logic\n        return true\n    }\n    \n    func intercept(_ request: inout URLRequest) {\n        // Add headers, tokens, etc.\n        request.addValue(\"Bearer \\(token)\", forHTTPHeaderField: \"Authorization\")\n    }\n    \n    func intercept(_ data: inout Data) {\n        // Process response data before decoding\n        // Example: decrypt data, modify response format\n    }\n    \n    func intercept(_ error: DecodableError) {\n        // Handle or process errors\n        // Example: refresh token on 401, log errors\n    }\n}\n\nlet controller = NetworkingController\u003cMyEndpoint, MyError\u003e(\n    interceptor: MyInterceptor()\n)\n```\n\n### JSON Mapping\n\nTransform API responses before decoding:\n\n```swift\nstruct User: Decodable, JsonMapper {\n    let id: String\n    let name: String\n    \n    static func map(_ data: Data) -\u003e Data {\n        // Transform response data if needed\n        return data\n    }\n}\n```\n\n### Retry Handling\n\nControl how many times a request should be retried after a failure. Retries apply to any thrown error (network, decoding, or interceptor-related) and use an exponential backoff that starts at `0.2s` and doubles with each retry. The initial request counts separately, so `retryCount` represents additional attempts (`retryCount = 2` -\u003e up to 3 total attempts).\n\n```swift\nextension MyEndpoint: Endpoint {\n    var retryCount: Int {\n        switch self {\n        case .getUser: 2   // Allow two retries (3 attempts total)\n        case .updateProfile: 0   // No retries\n        case .createPost: 1   // One retry (2 attempts total)\n        }\n    }\n}\n```\n\n### Logging Control\n\nConfigure logging per endpoint or globally:\n\n```swift\n// Per endpoint\nextension MyEndpoint: Endpoint {\n    var shouldPrintLogs: Bool {\n        switch self {\n        case .sensitiveData: false\n        default: true\n        }\n    }\n}\n\n// Global configuration\nNetworking.DebugConfiguration.shouldPrintLogs = true\n```\n\n## Requirements\n\n- Swift 5.9 or later\n- Xcode 15.0 or later\n- iOS 13.0 / macOS 10.15 / tvOS 13.0 / watchOS 6.0 or later\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelemtobi%2Fswift-networking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftelemtobi%2Fswift-networking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelemtobi%2Fswift-networking/lists"}