A Go implementation of a JSON-RPC 2.0 client over HTTP with support for batch requests, custom headers, and flexible response handling.
ybbus/jsonrpc is a Go library that implements a JSON-RPC 2.0 client for making remote procedure calls over HTTP. It handles the serialization of Go types into JSON-RPC requests and parses responses back into Go structs or primitives, simplifying communication with JSON-RPC servers. The library solves the problem of manually crafting JSON-RPC payloads and managing low-level HTTP details, providing a clean, type-safe API.
Go developers building applications that need to interact with JSON-RPC 2.0 servers, such as microservices, blockchain nodes, or any service exposing a JSON-RPC API. It's particularly useful for backend engineers integrating with external RPC-based services.
Developers choose this library because it is lightweight, spec-compliant, and offers both high-level convenience functions like `CallFor()` for quick integration and low-level control for advanced scenarios. Its support for batch requests, custom HTTP clients, and detailed error handling makes it a robust alternative to rolling your own client.
A simple go implementation of json rpc 2.0 client over http
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Automatically serializes Go primitives, structs, slices, and maps into valid JSON-RPC requests, as demonstrated with examples like structs and maps in the README.
Provides helper methods like GetInt() and CallFor() to easily parse responses into Go types, reducing boilerplate code for common use cases.
Allows sending multiple JSON-RPC requests in a single HTTP call with mapping utilities like AsMap() for efficient response retrieval, as shown in the batch examples.
Supports custom HTTP clients for proxies, TLS, or OAuth2 authentication, offering flexibility for secure or complex network environments, with examples in the README.
Distinguishes between network errors, HTTP errors, and JSON-RPC protocol errors with typed error objects like HTTPError, enabling precise error management.
The library is designed solely as a client; developers needing a JSON-RPC server must find or implement another solution, which adds complexity for full-stack projects.
Only supports HTTP transport, lacking built-in support for other protocols like WebSockets, which may be required for real-time or bidirectional communication scenarios.
Does not include automatic retry mechanisms or circuit breakers for handling transient failures, requiring manual implementation for robust production use.
For very simple RPC calls, the overhead of initializing the client and using helper methods might be more than necessary compared to direct HTTP requests, though it offers more features.