{"id":15642025,"url":"https://github.com/shekohex/jsonrpc-ts","last_synced_at":"2025-08-22T01:32:47.262Z","repository":{"id":40835882,"uuid":"151620715","full_name":"shekohex/jsonrpc-ts","owner":"shekohex","description":"Strongly 💪 Typed Fast and lightweight JSON RPC 2.0 Client for Nodejs","archived":false,"fork":false,"pushed_at":"2023-09-27T11:25:33.000Z","size":1169,"stargazers_count":66,"open_issues_count":15,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-09T20:12:15.245Z","etag":null,"topics":["json-rpc","jsonrpc-js","jsonrpc2","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/shekohex.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":"2018-10-04T18:50:46.000Z","updated_at":"2024-07-17T23:47:15.000Z","dependencies_parsed_at":"2024-06-19T00:06:37.785Z","dependency_job_id":"facdbb27-5fcb-4399-ab70-2dc960131eeb","html_url":"https://github.com/shekohex/jsonrpc-ts","commit_stats":{"total_commits":49,"total_committers":5,"mean_commits":9.8,"dds":0.3877551020408163,"last_synced_commit":"067bd48d1fcfee469b1860789ff159181d23eac7"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shekohex%2Fjsonrpc-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shekohex%2Fjsonrpc-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shekohex%2Fjsonrpc-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shekohex%2Fjsonrpc-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shekohex","download_url":"https://codeload.github.com/shekohex/jsonrpc-ts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230547678,"owners_count":18243227,"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":["json-rpc","jsonrpc-js","jsonrpc2","typescript"],"created_at":"2024-10-03T11:53:38.770Z","updated_at":"2024-12-20T07:07:13.887Z","avatar_url":"https://github.com/shekohex.png","language":"TypeScript","readme":"# JSONRPC Typescript\n\n[![Build Status](https://travis-ci.org/shekohex/jsonrpc-ts.svg?branch=master)](https://travis-ci.org/shekohex/jsonrpc-ts) [![Greenkeeper badge](https://badges.greenkeeper.io/shekohex/jsonrpc-ts.svg)](https://greenkeeper.io/)\n[![Coverage Status](https://coveralls.io/repos/github/shekohex/jsonrpc-ts/badge.svg?branch=master)](https://coveralls.io/github/shekohex/jsonrpc-ts?branch=master)\n[![npm version](https://badge.fury.io/js/jsonrpc-ts.svg)](https://badge.fury.io/js/jsonrpc-ts)\n\nStrongly 💪 Typed JSON RPC 2.0 Client for Nodejs\n\nFully tested to comply with the [official JSON-RPC 2.0 specification](https://www.jsonrpc.org/specification)\n\n## Quick Overview\n\nBy Declaring events using a simple interface mapping methods names to their parameters to get Strongly Typed, Fast and Modern Rpc client for your service.\n\n## Install\n\n```\nnpm i jsonrpc-ts\n```\n\n## Usage\n\nFirst you need to define your Methods, that could be achieved by creating an interface of methods name and there parameters.\n\n```ts\n// we have a service that can do math,\n// and it has this methods\ninterface MathService {\n  // a method called sum that accepts 2 args of type number\n  sum: [number, number];\n  // methods can have named paramerter too.\n  sub: { left: number; right: number };\n  // or if you need return type, you can have that too :)\n  sumWithReturnType: ({ x, y }: { x: number; y: number }) =\u003e number;\n}\n```\n\nthen import `RpcClient` and start making requests\n\n```ts\nimport { RpcClient } from 'jsonrpc-ts';\n\nconst rpcClient = new RpcClient\u003cMathService\u003e({ url: '...' });\n// now you have a strongly typed methods.\n// try to change [3, 2] to ['3', '2'] and the typescript compiler will catch you !\nconst response = await rpcClient.makeRequest({\n  method: 'sum',\n  params: [3, 2],\n  id: 1,\n  jsonrpc: '2.0',\n});\n// response.data.result === 5\n\n// response2.data.result has type of number :)\nconst response2 = await rpcClient.makeRequest({\n  method: 'sumWithReturnType',\n  params: { x: 3, y: 2 },\n  id: 2,\n  jsonrpc: '2.0',\n});\n// response2.data.result === 5\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshekohex%2Fjsonrpc-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshekohex%2Fjsonrpc-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshekohex%2Fjsonrpc-ts/lists"}