JSON-RPC: Lightweight Remote Procedure Call Protocol
Client-server communication protocol using JSON to invoke remote methods with simple, standardized syntax.
Updated on March 30, 2026
JSON-RPC is a stateless remote procedure call (RPC) protocol that uses JSON as its data encoding format. It enables applications to invoke methods on remote servers as if they were local, defining a simple message structure with requests, responses, and notifications. Widely adopted in blockchain applications, IoT APIs, and distributed systems, JSON-RPC offers a lightweight alternative to more complex protocols like SOAP or gRPC.
Protocol Fundamentals
- Standardized message structure with jsonrpc, method, params, and id fields
- Transport agnostic: compatible with HTTP, WebSocket, TCP, or other protocols
- Three message types: requests (expecting response), responses, and notifications (no response)
- Structured error handling with standardized codes and custom messages
Benefits of JSON-RPC
- Simplicity: minimalist syntax facilitating implementation and debugging
- Interoperability: JSON readable by virtually all programming languages
- Low overhead: compact payload compared to XML/SOAP
- Native batching: ability to send multiple requests in a single transaction
- Open specification: standardized and community-maintained
Practical Communication Example
// JSON-RPC 2.0 Request
const request = {
jsonrpc: "2.0",
method: "user.getProfile",
params: { userId: 12345 },
id: 1
};
// Success Response
const successResponse = {
jsonrpc: "2.0",
result: {
userId: 12345,
name: "Alice Smith",
email: "[email protected]"
},
id: 1
};
// Error Response
const errorResponse = {
jsonrpc: "2.0",
error: {
code: -32602,
message: "Invalid params",
data: "userId must be a positive integer"
},
id: 1
};
// Notification (no response expected)
const notification = {
jsonrpc: "2.0",
method: "user.logActivity",
params: { action: "login", timestamp: Date.now() }
// No 'id' field
};Implementation Steps
- Define API contract: list exposed methods and their signatures
- Choose transport layer (HTTP POST is most common)
- Implement server with method router and params validation
- Handle errors using standard codes (-32700 to -32603) and custom ones
- Add authentication/authorization at transport level (e.g., Bearer token)
- Document available methods with request/response examples
- Test with tools like Postman or dedicated JSON-RPC clients
Pro Tip
For public APIs, implement JSON-RPC batching to reduce latency: clients can send an array of requests and receive a corresponding array of responses. This significantly reduces network round-trips in interfaces requiring multiple simultaneous calls.
Tools and Libraries
- jayson (Node.js): complete client/server JSON-RPC library
- json-rpc-2.0 (TypeScript): typed implementation with Promise support
- ethereum-rpc (blockchain): JSON-RPC client for Ethereum
- jsonrpcserver/client (Python): toolset for Python 3
- Postman/Insomnia: manual testing with JSON-RPC templates
JSON-RPC establishes itself as a pragmatic solution for distributed architectures requiring simple and efficient communication. Its lightweight nature makes it a preferred choice for microservices, blockchain applications, and IoT systems where bandwidth and integration simplicity are critical. Adopting this protocol reduces infrastructure complexity while maintaining maximum compatibility between heterogeneous systems.
Let's talk about your project
Need expert help on this topic?
Our team supports you from strategy to production. Let's chat 30 min about your project.

