{"id":20683194,"url":"https://github.com/chimehq/jsonrpc","last_synced_at":"2025-09-07T06:37:01.199Z","repository":{"id":46805541,"uuid":"387825528","full_name":"ChimeHQ/JSONRPC","owner":"ChimeHQ","description":"Swift library for JSON-RPC","archived":false,"fork":false,"pushed_at":"2025-05-08T14:30:17.000Z","size":152,"stargazers_count":37,"open_issues_count":2,"forks_count":12,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-07T06:37:00.199Z","etag":null,"topics":["ios","json-rpc","jsonrpc","macos","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChimeHQ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["mattmassicotte"]}},"created_at":"2021-07-20T14:53:35.000Z","updated_at":"2025-05-08T14:28:27.000Z","dependencies_parsed_at":"2023-09-23T07:17:01.916Z","dependency_job_id":"7595e64c-48e7-447e-9926-0e13a45417fc","html_url":"https://github.com/ChimeHQ/JSONRPC","commit_stats":{"total_commits":43,"total_committers":3,"mean_commits":"14.333333333333334","dds":0.06976744186046513,"last_synced_commit":"e9c2ada4f4423384107091be34aa55db597d9829"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/ChimeHQ/JSONRPC","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FJSONRPC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FJSONRPC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FJSONRPC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FJSONRPC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChimeHQ","download_url":"https://codeload.github.com/ChimeHQ/JSONRPC/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FJSONRPC/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274005336,"owners_count":25205934,"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-09-07T02:00:09.463Z","response_time":67,"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":["ios","json-rpc","jsonrpc","macos","swift"],"created_at":"2024-11-16T22:15:53.065Z","updated_at":"2025-09-07T06:37:01.189Z","avatar_url":"https://github.com/ChimeHQ.png","language":"Swift","funding_links":["https://github.com/sponsors/mattmassicotte"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n[![Build Status][build status badge]][build status]\n[![Platforms][platforms badge]][platforms]\n[![Documentation][documentation badge]][documentation]\n[![Matrix][matrix badge]][matrix]\n\n\u003c/div\u003e\n\n# JSONRPC\nA simple Swift library for [JSON-RPC](https://www.jsonrpc.org)\n\nFeatures:\n- type-safety\n- flexible data transport support\n- concurrency support\n\n## Integration\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/ChimeHQ/JSONRPC\", from: \"0.9.0\")\n]\n```\n\n## Usage\n\nThe core type you'll use is `JSONRPCSession`. It requires you set up a `DataChannel` object that handles reading and writing raw data.\n\n```swift\nlet channel = DataChannel(...)\nlet session = JSONRPCSession(channel: channel)\n\nlet params = \"hello\" // any Encodable\nlet response: Decodable = try await session.sendRequest(params, method: \"my_method\")\n\nTask {\n    for await event in await session.eventSequence {\n        switch event {\n        case .request(let request, let handler, let data):\n            // inspect request, possibly re-decode with more specific type,\n            // and reply using the handler\n\n        case .notification(let notification, let data):\n            // inspect notification\n        case .error(let error):\n            print(\"Error: \\(error)\")\n        }\n    }\n}\n```\n\n### DataChannel\n\nThe closures on the `DataChannel` allow different transport mechanisms to be used. The `JSONRPC` package provides a few basic variants:\n\n- Predefined messages channel\n  - A channel that delivers a static set of messages\n  - Usage: `let channel = await DataChannel.predefinedMessagesChannel(with: messages)`\n- Stdio channel\n  - Using stdout + stdin as message transport.\n  - Note: When using this transport, make sure no non-protocol messages are sent to `stdout`, eg using `print`\n  - Usage: `let channel = DataChannel.stdioPipe()`\n- Actor channel\n  - Using swift actors to pass messages.\n  - Can eg be useful for testing, where both client and server are implemented in swift and running in the same process.\n  - Usage: `let (clientChannel, serverChannel) = DataChannel.withDataActor()`\n- WebSocket channel\n  - Uses `URLSessionWebSocketTask` as a message transport.\n  - Usage: `let channel = DataChannel.webSocket(url: socketURL, terminationHandler: { print(\"socket closed\" })`\n\n## Contributing and Collaboration\n\nI would love to hear from you! Issues or pull requests work great. Both a [Matrix space][matrix] and [Discord][discord] are available for live help, but I have a strong bias towards answering in the form of documentation. You can also find me on [mastodon](https://mastodon.social/@mattiem).\n\nI prefer collaboration, and would love to find ways to work together if you have a similar project.\n\nI prefer indentation with tabs for improved accessibility. But, I'd rather you use the system you want and make a PR than hesitate because of whitespace.\n\nBy participating in this project you agree to abide by the [Contributor Code of Conduct](CODE_OF_CONDUCT.md).\n\n[build status]: https://github.com/ChimeHQ/JSONRPC/actions\n[build status badge]: https://github.com/ChimeHQ/JSONRPC/workflows/CI/badge.svg\n[license]: https://opensource.org/licenses/BSD-3-Clause\n[license badge]: https://img.shields.io/github/license/ChimeHQ/JSONRPC\n[platforms]: https://swiftpackageindex.com/ChimeHQ/JSONRPC\n[platforms badge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FChimeHQ%2FJSONRPC%2Fbadge%3Ftype%3Dplatforms\n[documentation]: https://swiftpackageindex.com/ChimeHQ/JSONRPC/main/documentation\n[documentation badge]: https://img.shields.io/badge/Documentation-DocC-blue\n[matrix]: https://matrix.to/#/%23chimehq%3Amatrix.org\n[matrix badge]: https://img.shields.io/matrix/chimehq%3Amatrix.org?label=Matrix\n[discord]: https://discord.gg/esFpX6sErJ\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchimehq%2Fjsonrpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchimehq%2Fjsonrpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchimehq%2Fjsonrpc/lists"}