{"id":21900583,"url":"https://github.com/dzns/dznetworking","last_synced_at":"2025-04-15T19:53:56.323Z","repository":{"id":34874229,"uuid":"38882938","full_name":"DZNS/DZNetworking","owner":"DZNS","description":"Simple URLSession wrapper and additional convenience classes. ","archived":false,"fork":false,"pushed_at":"2024-08-08T03:16:07.000Z","size":1488,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-15T19:53:53.592Z","etag":null,"topics":["codable","concurrency","ios","macos","networking","swift","tvos","urlsession","watchos"],"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/DZNS.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-07-10T14:02:55.000Z","updated_at":"2024-08-08T03:16:10.000Z","dependencies_parsed_at":"2024-01-01T04:44:46.370Z","dependency_job_id":"527d46b6-09ea-462d-9bcc-cdbb06521c22","html_url":"https://github.com/DZNS/DZNetworking","commit_stats":null,"previous_names":[],"tags_count":56,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DZNS%2FDZNetworking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DZNS%2FDZNetworking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DZNS%2FDZNetworking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DZNS%2FDZNetworking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DZNS","download_url":"https://codeload.github.com/DZNS/DZNetworking/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249145295,"owners_count":21219966,"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":["codable","concurrency","ios","macos","networking","swift","tvos","urlsession","watchos"],"created_at":"2024-11-28T15:09:04.777Z","updated_at":"2025-04-15T19:53:56.306Z","avatar_url":"https://github.com/DZNS.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DZNetworking v3\n\n`URLSession` based networking supporting Swift Concurrency and completion block handler style APIs.\n\nDZNetworking exposes simple APIs that make constructing networking models with REST APIs easy. \n\nThe API is straight-forward, well tested and extensible. DZNetworking should be treated as a simple wrapper around `URLSession`.\n\n### Supports \n- `URLSession` data, download and upload tasks\n- Uploads to S3 buckets\n- OAuth2 session handler \n\n### Instantiating\n\nDZURLSession makes it really easy to get started. Here's a sample:\n\n```swift\nlet session = DZURLSession()\nsession.baseURL = URL(string:\"http://api.myapp.com/\")!\n\nlet (data, _) = try await session.GET(\"/posts\", query: [\"userID\": \"1\"]) \n``` \n\n---\n\nThe `DZJSONResponseParser` implements the `DZResponseParser` protocol which handles parsing JSON responses. You can implement your own response parsers (example: XML, YAML, etc.) by conforming your parser to `DZResponseParser`.\n\nYou must then assign that response parser to the DZURLSession before making network requests.\n\n```swift\nlet session = DZURLSession()\nsession.responseParser = DZJSONResponseParser()\n``` \n\n---\n\nThe `DZURLSession` class also comes with `requestModifier` block. This is useful when you need to modify all or most requests in a similar fashion before they are sent over the wire. \n\nA good use-case would be appending oAuth headers/query parameters to requests. This leaves your networking methods in your subclass clean and easily debuggable. \n\n```swift\nsession.requestModifier = { [weak self] request in\n  guard let self else {\n    return request\n  }\n\n  var uri = request.url?.absoluteString ?? \"\"\n  if uri.contains(\"?\") {\n    // already have query params, append\n    uri.append(self.extraQueryParams)\n  }\n  else {\n    uri = uri.appendingFormat(\"?%@\", self.extraQueryParams)\n  }\n\n  request.url = URL(string: uri)\n  return request\n}\n```\n\n---\n\n### Documentation\n\nI've tried my best to document most methods properly. All documentation is in the `DocC` format in the source files. \n\nIf you believe you require clarifcation on something, please open an issue, appropriately tagged, and I'll try to either:\n- include documentation, if missing.\n- improve documentation, if incorrect.\n- try to answer the issue in the thread, if already correctly documented.\n\n---\n\n### Supported HTTP Methods\n\n- HEAD\n- OPTIONS\n- GET\n- POST\n- PUT\n- PATCH\n- DELETE\n\n---\n\n### Pull Requests \u0026 Issues\n\nIf you'd like to contribute, please open a Pull Request. If you are encountering bugs, please open an Issue. Don't forget to tag it appropriately, and be nice to others.\n\nIf you see an opportunity to improve the tests suite, your additions will be much appreciated.\n\n---\n\n### LICENSE\n\nDZNetworking is licensed under the MIT License. Complete information can be found in the License file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdzns%2Fdznetworking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdzns%2Fdznetworking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdzns%2Fdznetworking/lists"}