{"id":1660,"url":"https://github.com/STDevTM/RxRestClient","last_synced_at":"2025-08-02T04:32:10.945Z","repository":{"id":42018661,"uuid":"127706935","full_name":"STDevTM/RxRestClient","owner":"STDevTM","description":"Simple REST Client based on RxSwift and Alamofire.","archived":false,"fork":false,"pushed_at":"2023-03-17T05:53:54.000Z","size":504,"stargazers_count":16,"open_issues_count":1,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-27T08:46:27.049Z","etag":null,"topics":["alamofire","reactivex","rest","rest-api","rxswift"],"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/STDevTM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-04-02T05:32:49.000Z","updated_at":"2022-11-19T21:03:40.000Z","dependencies_parsed_at":"2024-01-07T22:23:30.186Z","dependency_job_id":"cb232173-51ca-456b-b7cb-f139d2b271d7","html_url":"https://github.com/STDevTM/RxRestClient","commit_stats":{"total_commits":109,"total_committers":9,"mean_commits":12.11111111111111,"dds":0.4954128440366973,"last_synced_commit":"f5b841682145637f8df0bf9997aa61e9b7c98628"},"previous_names":["stdevteam/rxrestclient"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/STDevTM/RxRestClient","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/STDevTM%2FRxRestClient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/STDevTM%2FRxRestClient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/STDevTM%2FRxRestClient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/STDevTM%2FRxRestClient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/STDevTM","download_url":"https://codeload.github.com/STDevTM/RxRestClient/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/STDevTM%2FRxRestClient/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268334615,"owners_count":24233793,"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-02T02:00:12.353Z","response_time":74,"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":["alamofire","reactivex","rest","rest-api","rxswift"],"created_at":"2024-01-05T20:15:52.572Z","updated_at":"2025-08-02T04:32:10.911Z","avatar_url":"https://github.com/STDevTM.png","language":"Swift","readme":"# RxRestClient\n\n[![CI Status](https://github.com/STDevTM/RxRestClient/workflows/RxRestClient/badge.svg?branch=master)](https://github.com/STDevTM/RxRestClient/actions)\n[![Version](https://img.shields.io/cocoapods/v/RxRestClient.svg?style=flat)](https://cocoapods.org/pods/RxRestClient)\n[![License](https://img.shields.io/cocoapods/l/RxRestClient.svg?style=flat)](https://cocoapods.org/pods/RxRestClient)\n[![Platform](https://img.shields.io/cocoapods/p/RxRestClient.svg?style=flat)](https://stdevtm.github.io/RxRestClient/)\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## Requirements\n\n* iOS 10.0+\n* tvOS 10.0+\n* macOS 10.12+\n* Swift 5.6+\n* Xcode 13+\n\n## Migration Guides\n\n- [RxRestClient 2.0 Migration Guide](./Documentation/RxRestClient%202.0%20Migration%20Guide.md)\n\n## Installation\n\n\u003cdetails\u003e\n\u003csummary\u003eCocoaPods\u003c/summary\u003e\n\u003c/br\u003e\n\u003cp\u003eRxRestClient is available through \u003ca href=\"http://cocoapods.org\"\u003eCocoaPods\u003c/a\u003e. To install it, simply add the following line to your \u003ccode\u003ePodfile\u003c/code\u003e:\u003c/p\u003e\n\n\u003cpre\u003e\u003ccode class=\"ruby language-ruby\"\u003epod 'RxRestClient'\u003c/code\u003e\u003c/pre\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eSwift Package Manager\u003c/summary\u003e\n\u003c/br\u003e\n\u003cp\u003eYou can use \u003ca href=\"https://swift.org/package-manager\"\u003eThe Swift Package Manager\u003c/a\u003e to install \u003ccode\u003eRxRestClient\u003c/code\u003e by adding the proper description to your \u003ccode\u003ePackage.swift\u003c/code\u003e file:\u003c/p\u003e\n\n\u003cpre\u003e\u003ccode class=\"swift language-swift\"\u003eimport PackageDescription\n\nlet package = Package(\n    name: \"YOUR_PROJECT_NAME\",\n    targets: [],\n    dependencies: [\n        .package(url: \"https://github.com/STDevTM/RxRestClient.git\", from: \"2.1.0\")\n    ]\n)\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003cp\u003eNext, add \u003ccode\u003eRxRestClient\u003c/code\u003e to your targets dependencies like so:\u003c/p\u003e\n\u003cpre\u003e\u003ccode class=\"swift language-swift\"\u003e.target(\n    name: \"YOUR_TARGET_NAME\",\n    dependencies: [\n        \"RxRestClient\",\n    ]\n),\u003c/code\u003e\u003c/pre\u003e\n\u003cp\u003eThen run \u003ccode\u003eswift package update\u003c/code\u003e.\u003c/p\u003e\n\n\u003c/details\u003e\n\n## Features\n\n* Simple way to do requests\n* Simple way to have response state in reactive way\n* Ability to customization\n* Retry on any error\n* Handle network reachability status\n* Retry on become reachable\n* Ability to use absolute and relative urls\n* Swift Codable protocol support\n* Use custom SessionManager\n* Pagination support\n* [Complete Documentation](https://stdevtm.github.io/RxRestClient/)\n* _more coming soon_\n\n## How to use\n\nFirst of all you need to create `struct` of your response state and implement `ResponseState` protocol.\n\n```swift\nstruct RepositoriesState: ResponseState {\n\n    typealias Body = Data\n\n    var state: BaseState?\n    var data: [Repository]?\n\n    private init() {\n        state = nil\n    }\n\n    init(state: BaseState) {\n        self.state = state\n    }\n\n    init(response: (HTTPURLResponse, Data?)) {\n        if response.0.statusCode == 200, let body = response.1 {\n            self.data = try? JSONDecoder().decode(RepositoryResponse.self, from: body).items\n        }\n    }\n\n    static let empty = RepositoriesState()\n}\n```\n\nIt is required to mention expected Body type (`String` or `Data`).\n\nAfter that you need to create request model:\n\n```swift\nstruct RepositoryQuery: Encodable {\n    let q: String\n}\n\n```\n\nThen you can do the request to get repositories:\n\n```swift\nimport RxSwift\nimport RxRestClient\n\nprotocol RepositoriesServiceProtocol {\n    func get(query: RepositoryQuery) -\u003e Observable\u003cRepositoriesState\u003e\n}\n\nfinal class RepositoriesService: RepositoriesServiceProtocol {\n\n    private let client = RxRestClient()\n\n    func get(query: RepositoryQuery) -\u003e Observable\u003cRepositoriesState\u003e {\n        return client.get(\"https://api.github.com/search/repositories\", query: query)\n    }\n}\n\n```\n\nIn order to customize client you can use `RxRestClientOptions`:\n\n```swift\nvar options = RxRestClientOptions.default\noptions.addHeader(key: \"x-apikey\", value: \"\u003cAPI_KEY\u003e\")\nclient = RxRestClient(baseUrl: \u003cBASE _URL\u003e), options: options)\n```\n\n### Relative vs absolute url\n\nIn order to use relative url you need to give `\u003cBASE_URL\u003e` when initializing client object.\n\n```swift\nlet client = RxRestClient(baseURL: \u003cBASE_URL\u003e)\n```\n\nWhen calling any request you can provide either `String` endpoint or absolute `URL`. If you will `String` it will be appended to `baseURL`.\n\n```swift\nclient.get(\"rest/contacts\")\n```\n\nIf `baseURL` is `nil` then it will try to convert provided `String` to `URL`.\n\nIn order to use absolute url even when your client has `baseURL` you can provide `URL` like this:\n\n```swift\nif let url = URL(string: \"https://api.github.com/search/repositories\") {\n    client.get(url: url, query: [\"q\": search])\n}\n```\n\n### Pagination\n\nPagination support is working only for `GET` requests. In order to have pagination (or infinite scrolling) feature you need to implement following protocols for query and response models:\n\nFor query model you need to implement `PagingQueryProtocol`:\n\n```swift\nstruct RepositoryQuery: PagingQueryProtocol {\n\n    let q: String\n    var page: Int\n\n    init(q: String) {\n        self.q = q\n        self.page = 1\n    }\n\n    func nextPage() -\u003e RepositoryQuery {\n        var new = self\n        new.page += 1\n        return new\n    }\n}\n```\n\nFor response model you need to implement `PagingResponseProtocol`:\n\n```swift\nstruct RepositoryResponse: PagingResponseProtocol {\n    let totalCount: Int\n    var repositories: [Repository]\n\n    private enum CodingKeys: String, CodingKey {\n        case totalCount = \"total_count\"\n        case repositories = \"items\"\n    }\n\n    // MARK: - PagingResponseProtocol\n    typealias Item = Repository\n\n    static var decoder: JSONDecoder {\n        return .init()\n    }\n\n    var canLoadMore: Bool {\n        return totalCount \u003e items.count\n    }\n\n    var items: [Repository] {\n        get {\n            return repositories\n        }\n        set(newValue) {\n            repositories = newValue\n        }\n    }\n\n}\n```\n\nFor response states you need to use `PagingState` class or custom subclass:\n\n```swift\nfinal class RepositoriesState: PagingState\u003cRepositoryResponse\u003e {\n    ...\n}\n```\n\nAfter having all necessary models you can do your request:\n\n```swift\nclient.get(\"https://api.github.com/search/repositories\", query: query, loadNextPageTrigger: loadNextPageTrigger)\n```\n\n`loadNextPageTrigger` is an `Observable` with `Void` type in order to trigger client to do request for next page using new query model generated using `nextPage()` function. \n\n## Author\n\nTigran Hambardzumyan, tigran@stdevmail.com\n\n## Support\n\nFeel free to [open issues](https://github.com/stdevteam/RxRestClient/issues/new) with any suggestions, bug reports, feature requests, questions.\n\n## Let us know!\n\nWe’d be really happy if you sent us links to your projects where you use our component. Just send an email to developer@stdevmail.com and do let us know if you have any questions or suggestion.\n\n## License\n\nRxRestClient is available under the MIT license. See the LICENSE file for more info.\n","funding_links":[],"categories":["Networking"],"sub_categories":["Video"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSTDevTM%2FRxRestClient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSTDevTM%2FRxRestClient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSTDevTM%2FRxRestClient/lists"}