JSON-RPC - JavaScript Object Notation – Remote Procedure Call ================================================================ .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is JSON-RPC?** JSON-RPC is a **remote procedure call (RPC) protocol** encoded in **JSON (JavaScript Object Notation)**. It allows data to be exchanged between a client and a server in a simple, lightweight format. It is transport-agnostic and widely used in web and distributed systems. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Why is JSON-RPC useful?** JSON-RPC is useful because it is: - **Lightweight** and easy to implement - **Human-readable** due to JSON formatting - **Language-independent**, enabling communication between systems written in different languages - Suitable for systems where minimal overhead and simplicity are required .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **How it works?** JSON-RPC uses standard JSON to encode requests and responses: - The **client** sends a request with a method name, parameters, and an ID. - The **server** executes the method and responds with the result or an error. - JSON-RPC supports **notifications** (requests without responses) and **batch requests** (multiple requests in one message). It does **not** define a transport layer, so it can work over HTTP, WebSocket, TCP, etc. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Where is JSON-RPC used?** JSON-RPC is commonly used in: - **Cryptocurrency APIs** (e.g., Bitcoin, Ethereum nodes) - **Web applications** for AJAX communication - **IoT systems** and lightweight services - **Microservices** needing simple RPC mechanisms .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which OSI layer does this protocol belong to?** JSON-RPC operates at the **Application Layer (Layer 7)** of the OSI model. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is JSON-RPC Windows specific?** No, JSON-RPC is **not Windows specific**. It is platform-independent and can be used on any operating system that supports JSON and network communication. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is JSON-RPC Linux specific?** No, JSON-RPC is **not Linux specific**. It is equally usable on Linux, macOS, Windows, and embedded systems. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which Transport Protocol is used by JSON-RPC?** JSON-RPC is **transport-agnostic**. Common transport protocols include: - **HTTP/HTTPS** - **WebSocket** - **TCP** - **Unix Domain Sockets** .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which Port is used by JSON-RPC?** JSON-RPC **does not define a specific port**. The port depends on the transport used (e.g., HTTP on port 80 or 443, WebSocket on configurable ports). For example, Bitcoin's JSON-RPC typically runs on **port 8332**. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is JSON-RPC using Client server model?** Yes, JSON-RPC follows a **client-server model**: - The **client** initiates requests to call remote methods. - The **server** executes those methods and returns results or errors. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Topics in this section, * :ref:`Learnings in this section ` * :ref:`Terminology ` * :ref:`Version Info ` * :ref:`JSON-RPC Version&IEEE Details ` * :ref:`JSON-RPC Basic Setup on Ubuntu using IPv4 ` * :ref:`JSON-RPC Basic Setup on Ubuntu using IPv6 ` * :ref:`JSON-RPC Protocol Packet Details ` * :ref:`JSON-RPC Usecases ` * :ref:`JSON-RPC Basic Features ` * :ref:`Reference links ` .. _JSON-RPC_step1: .. tab-set:: .. tab-item:: Learnings in this section * In this section, you are going to learn .. _JSON-RPC_step2: .. tab-set:: .. tab-item:: Terminology * Terminology .. _JSON-RPC_step3: .. tab-set:: .. tab-item:: Version Info * Version Info .. _JSON-RPC_step5: .. tab-set:: .. tab-item:: JSON-RPC Version&RFC Details * rfc details .. _JSON-RPC_step18: .. tab-set:: .. tab-item:: JSON-RPC Basic Setup on Ubuntu using IPv4 * setup .. _JSON-RPC_step19: .. tab-set:: .. tab-item:: JSON-RPC Basic Setup on Ubuntu using IPv6 * setup .. _JSON-RPC_step6: .. tab-set:: .. tab-item:: JSON-RPC Protocol Packet Details * packet details .. _JSON-RPC_step7: .. tab-set:: .. tab-item:: JSON-RPC Usecases * usecases .. _JSON-RPC_step8: .. tab-set:: .. tab-item:: JSON-RPC Basic Features * features .. _JSON-RPC_step17: .. tab-set:: .. tab-item:: Reference links * Reference links