{"id":37169041,"url":"https://github.com/liquidcats/jsonrpc","last_synced_at":"2026-01-14T19:57:54.073Z","repository":{"id":284198879,"uuid":"954128802","full_name":"LiquidCats/jsonrpc","owner":"LiquidCats","description":"Small and powerful JSON RPC client","archived":false,"fork":false,"pushed_at":"2025-10-16T21:54:41.000Z","size":177,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-17T23:15:21.816Z","etag":null,"topics":["client","http","json-rpc","json-rpc-client","json-rpc2","rpc"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LiquidCats.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-24T15:50:52.000Z","updated_at":"2025-10-16T21:50:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"fe04e605-10d8-4fc2-92bf-4ab64d7eb984","html_url":"https://github.com/LiquidCats/jsonrpc","commit_stats":null,"previous_names":["liquidcats/jsonrpc"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/LiquidCats/jsonrpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiquidCats%2Fjsonrpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiquidCats%2Fjsonrpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiquidCats%2Fjsonrpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiquidCats%2Fjsonrpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LiquidCats","download_url":"https://codeload.github.com/LiquidCats/jsonrpc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiquidCats%2Fjsonrpc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28433829,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"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":["client","http","json-rpc","json-rpc-client","json-rpc2","rpc"],"created_at":"2026-01-14T19:57:53.345Z","updated_at":"2026-01-14T19:57:54.063Z","avatar_url":"https://github.com/LiquidCats.png","language":"Go","readme":"# JSON‑RPC Client for Go\n\nA lightweight, type‑safe client that implements the JSON‑RPC 2.0 specification over HTTP.  \nIt uses the high‑performance **sonic** JSON library for encoding/decoding and\nthe robust **eris** package for error handling.\n\n## Features\n\n- Fully typed requests \u0026 responses via generics.\n- Zero‑alloc JSON with *sonic*.\n- Extensible options: request‑level (headers, context, content‑type) and client‑level.\n- Production‑ready HTTP client with tuned timeouts, connection pooling and HTTP/2.\n- Rich error handling: JSON‑RPC errors are wrapped in `jsonrpc.RPCError`.\n\n## Installation\n\n```bash\ngo get github.com/LiquidCats/jsonrpc/v2\n```\n\n\u003e The module is published under the `v2` path. Use that import path in your\n\u003e projects.\n\n## Usage\n\n### 1. Create a request\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/LiquidCats/jsonrpc/v2\"\n)\n\nfunc main() {\n\ttype Params struct{ Value int }\n\n\t// Create a request that expects a string result.\n\treq := jsonrpc.NewRequest[Params, string](\n\t\t\"exampleMethod\",\n\t\tParams{Value: 123},\n\t)\n\n\t// Prepare the request for a specific endpoint.\n\tpReq := req.Prepare(\"https://your.rpc\")\n\n\t// Execute with the library’s default HTTP client.\n\tresult, err := pReq.Execute(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"request failed: %v\", err)\n\t}\n\n\tfmt.Printf(\"Result: %s\\n\", *result)\n}\n```\n\n### 2. Customising a request\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\n\t\"github.com/LiquidCats/jsonrpc/v2\"\n)\n\nfunc main() {\n\treq := jsonrpc.NewRequest[map[string]int, string](\n\t\t\"exampleMethod\",\n\t\tmap[string]int{\"value\": 123},\n\t)\n\n\tpReq := req.Prepare(\n\t\t\"https://your.rpc\",\n\t\tjsonrpc.WithHeader(\"Authorization\", \"Bearer token\"),\n\t\tjsonrpc.WithContext(context.Background()),\n\t)\n\n\tresult, err := pReq.Execute(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"request failed: %v\", err)\n\t}\n\n\tfmt.Printf(\"Result: %s\\n\", *result)\n}\n```\n\n### 3. Using a custom HTTP client\n\n```go\npackage main\n\nimport (\n\t\"net/http\"\n\t\"time\"\n\n\t\"github.com/LiquidCats/jsonrpc/v2\"\n)\n\nfunc main() {\n\treq := jsonrpc.NewRequest[struct{}, string](\"ping\", struct{}{})\n\tpReq := req.Prepare(\"https://your.rpc\")\n\n\t// Custom client with a 10‑second timeout.\n\tcustom := \u0026http.Client{Timeout: 10 * time.Second}\n\n\tresult, err := pReq.Execute(custom)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tprintln(*result)\n}\n```\n\n## API Reference\n\n### `NewRequest[Params any, Result any](method string, params Params) *rpcRequest[Params, Result]`\n\nCreates a new JSON‑RPC 2.0 request.\n\n| Parameter | Type   | Description          |\n|-----------|--------|----------------------|\n| `method`  | string | RPC method name.     |\n| `params`  | Params | Method parameters.   |\n\n### `(*rpcRequest[Params, Result]) Prepare(url string, opts ...PrepareOpt) *praparedRPCRequest[Result]`\n\nPrepares the request for a specific URL, applying any provided options.\n\n| Parameter | Type          | Description                          |\n|-----------|---------------|--------------------------------------|\n| `url`     | string        | Target endpoint.                     |\n| `opts`    | ...PrepareOpt | Request‑level options (headers, etc).|\n\n### `(*praparedRPCRequest[Result]) Execute(client *http.Client, opts ...ExecuteOpt) (*Result, error)`\n\nExecutes the prepared request.\n\n| Parameter | Type          | Description                                        |\n|-----------|---------------|----------------------------------------------------|\n| `client`  | *http.Client  | HTTP client to use; if nil, the library’s default is used. |\n| `opts`    | ...ExecuteOpt | Client‑level options (currently none).             |\n\n### Request‑level option helpers\n\n| Function | Signature | Description |\n|----------|-----------|-------------|\n| `WithContext(ctx context.Context)` | `func(context.Context) PrepareOpt` | Sets the request’s context. |\n| `WithHeader(key, value string)` | `func(string, string) PrepareOpt` | Adds or overrides an HTTP header. |\n| `WithContentType(contentType string)` | `func(string) PrepareOpt` | Sets the `Content‑Type` header. |\n\n### Error handling\n\n- JSON‑RPC errors returned by the server are wrapped in `jsonrpc.RPCError`, which implements the `error` interface.\n- HTTP status codes outside 2xx are returned as wrapped errors with the status code.\n\n## Performance Notes\n\n- **Connection pooling**: up to 4096 idle connections, 1024 per host.\n- **Buffers**: 64 KB read/write buffers for efficient I/O.\n- **HTTP/2**: enabled by default; multiplexed streams per connection.\n- **Compression**: gzip/deflate automatically handled (`DisableCompression: false`).\n- **TLS session cache**: 4096 entries.\n\n## Contributing\n\nFeel free to open issues or pull requests. All contributions are welcome!\n\n## License\n\nThis project is licensed under the GNU Affero General Public License v3.0 – see the [LICENSE](LICENSE) file for details.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliquidcats%2Fjsonrpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliquidcats%2Fjsonrpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliquidcats%2Fjsonrpc/lists"}