# JSON-RPC

> A way for one program to ask another to do a job. The note is in JSON.

**Field:** Software Development  
**Category:** APIs  
**Also known as:** JSON-RPC 2.0, JSON Remote Procedure Call

## Think of it like

Think of it like a note that says which job to do and what to use. The answer note has the same number.

## Definition

JSON-RPC is a simple way for one program to ask another to run a function, using JSON messages. A request names the method, gives its inputs and carries an id. The reply carries the same id, with either a result or an error. A message with no id is a notice that needs no reply. It does not care how the messages travel, so it works over HTTP, sockets or plain input and output. The current version, 2.0, dates from 2010.

## Example

Lucy's app sends a JSON-RPC request asking for the sum of 3 and 4, with id 1. The reply says the result is 7 and carries id 1, so she knows which request it answers.

## Example code

```json
{ "jsonrpc": "2.0", "method": "add", "params": [3, 4], "id": 1 }

{ "jsonrpc": "2.0", "result": 7, "id": 1 }
```

A request and its reply. The shared id ties the answer to the question.

## Why it matters

It is small and easy to read. MCP and many other tools are built on it.

## Common mistake

Reusing the same id for two requests at once. The replies can then be matched to the wrong question.

## Three principles

- **Method, inputs, id.** Every request.
- **Same id back.** Matches the reply.
- **Any channel.** HTTP, sockets or pipes.

## Related terms

- [Remote Procedure Call (RPC)](https://learn.benibix.com/term/development/remote-procedure-call)
- [JavaScript Object Notation (JSON)](https://learn.benibix.com/term/development/json)
- [Model Context Protocol (MCP)](https://learn.benibix.com/term/ai/model-context-protocol)
- [REST API](https://learn.benibix.com/term/development/rest-api)

![A request with a method name, the inputs and an id goes from client to server. The answer comes back with a result and the same id, so the client can match them up.](https://learn.benibix.com/diagrams/dev-json-rpc.svg)

---

Source: https://learn.benibix.com/term/development/json-rpc
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
