RPC (JSON-RPC, XML-RPC)
API - Application Programming Interface
2 min read
This section is 2 min read, full guide is 16 min read
Published Sep 24 2025, updated Aug 17 2026
8
Show sections list
0
Log in to enable the "Like" button
0
Guide comments
0
Log in to enable the "Save" button
Respond to this guide
Guide Sections
Guide Comments
API
RPC (Remote Procedure Call) is a communication method where a program calls a procedure (function) on a remote system as if it were local. The client sends a request to the server, which executes the procedure and returns a response.
RPC abstracts away the details of network communication, making remote calls look like local function calls.
Types of RPC
XML-RPC:
- Uses XML to encode requests and responses.
- Typically sent over HTTP.
Example request:
<?xml version="1.0"?><methodCall> <methodName>getUser</methodName> <params> <param><value><int>123</int></value></param> </params></methodCall>Example response:
<?xml version="1.0"?><methodResponse> <params> <param> <value> <struct> <member><name>id</name><value><int>123</int></value></member> <member><name>name</name><value><string>Alice</string></value></member> </struct> </value> </param> </params></methodResponse>SON-RPC
- Uses JSON for request/response.
- Lightweight and easier to parse than XML.
Example request:
{ "jsonrpc": "2.0", "method": "getUser", "params": { "id": 123 }, "id": 1}Example response:
{ "jsonrpc": "2.0", "result": { "id": 123, "name": "Alice" }, "id": 1}Key Features
- Method-centric → Call a function/method rather than accessing a resource.
- Synchronous → Client waits for server response (though async variants exist).
- Transport agnostic → Usually HTTP, but can use TCP or other protocols.
- Lightweight (JSON-RPC) vs Verbose (XML-RPC).
Advantages
- Simple model — “call a function remotely.”
- Easy to implement for small services.
- JSON-RPC is lightweight, readable, and fast for modern web apps.
Disadvantages
- Less standardised than SOAP or REST.
- Error handling can be inconsistent.
- Not ideal for complex enterprise workflows.
- Limited tooling and ecosystem compared to REST/GraphQL/gRPC.
Use Cases
- Internal services where simplicity is enough.
- Lightweight web services for data retrieval or small operations.
- Legacy systems using XML-RPC.
- Modern microservices or WebSocket-based services can use JSON-RPC