### JSON-RPC 2.0 Batch Requests/Responses Source: https://github.com/tunnckocore/jsonrpc-v2.0-spec/blob/master/jsonrpc-v2-spec.md Defines the rules for sending multiple JSON-RPC 2.0 requests in a single batch and the corresponding server response format. Covers parallel processing, response ordering, error handling for invalid requests, and empty batches. ```APIDOC JSON-RPC 2.0 Batch Requests/Responses: Client MAY send an Array containing Request objects to send multiple Requests at once. Server Processing: - SHOULD process batch requests in parallel. No guarantees about execution order. - MUST return a Response for each Request that requires one. - MUST return an Array containing corresponding Response objects. Order SHOULD match Request order if possible, but not guaranteed. Error Handling: - If batch request is invalid JSON: Server returns a single Response object with a Parse error. - If batch is an empty Array: Server returns an empty Array. - If batch contains invalid Request objects: Server returns a Response object for each invalid request, plus responses for valid requests. ``` ```json [ { "jsonrpc": "2.0", "method": "sum", "params": [1, 2, 4], "id": "1" }, { "jsonrpc": "2.0", "method": "notify_hello", "params": [7] }, { "jsonrpc": "2.0", "method": "subtract", "params": [42, 23], "id": "2" }, { "foo": "boo" }, { "jsonrpc": "2.0", "method": "get_data", "id": "9" } ] ``` ```json [ { "jsonrpc": "2.0", "result": 7, "id": "1" }, { "jsonrpc": "2.0", "result": 19, "id": "2" }, { "jsonrpc": "2.0", "error": { "code": -32600, "message": "Invalid Request" }, "id": null }, { "jsonrpc": "2.0", "result": ["hello", 5], "id": "9" } ] ``` -------------------------------- ### JSON-RPC 2.0 Request Object Structure Source: https://github.com/tunnckocore/jsonrpc-v2.0-spec/blob/master/jsonrpc-v2-spec.md Defines the structure of a JSON-RPC 2.0 Request object, used by clients to invoke methods on a server. It includes required fields like `jsonrpc`, `method`, and `id`, and an optional `params` field which can be an array or an object. ```APIDOC JSON-RPC 2.0 Request Object: A remote procedure call is made by sending a Request object to a server. Structure: * jsonrpc (String): REQUIRED. Specifies the JSON-RPC protocol version. MUST be exactly "2.0". * method (String): REQUIRED. The name of the method to be invoked. Method names starting with `rpc.` are reserved for internal methods and extensions. * params (Structured): OPTIONAL. An Object or Array containing parameter values for the method. If omitted, the method is assumed to take no parameters. * id (String | Number | Null): REQUIRED (unless it's a Notification). An identifier established by the Client. It MUST be a String, Number, or Null. If not included, it's treated as a Notification. The Server MUST reply with the same `id` in the Response object. Using `Null` is discouraged. Example (Positional Params): { "jsonrpc": "2.0", "method": "subtract", "params": [42, 23], "id": 1 } Example (Named Params): { "jsonrpc": "2.0", "method": "subtract", "params": { "subtrahend": 23, "minuend": 42 }, "id": 3 } ``` -------------------------------- ### JSON-RPC 2.0 Error Object Structure and Codes Source: https://github.com/tunnckocore/jsonrpc-v2.0-spec/blob/master/jsonrpc-v2-spec.md Defines the structure of the `error` object within a JSON-RPC 2.0 Response, including `code`, `message`, and optional `data`. It also lists the predefined error codes and their meanings. ```APIDOC JSON-RPC 2.0 Error Object: When an RPC call encounters an error, the Response object includes an `error` member with the following structure: * code (Number): REQUIRED. An integer indicating the error type. Predefined codes are in the range -32768 to -32000. * message (String): REQUIRED. A short description of the error. * data (Any): OPTIONAL. Primitive or Structured value containing additional information about the error. May be omitted. Predefined Error Codes: | Code | Message | Meaning | | :------ | :--------------- | :---------------------------------------------------------------------- | | -32700 | Parse error | Invalid JSON received by the server. Error parsing JSON text. | | -32600 | Invalid Request | The JSON sent is not a valid Request object. | | -32601 | Method not found | The method does not exist or is not available. | | -32602 | Invalid params | Invalid method parameter(s). | | -32603 | Internal error | Internal JSON-RPC error. | | -32000 to -32099 | Server error | Reserved for implementation-defined server-errors. | ``` -------------------------------- ### JSON-RPC 2.0 Response Object Structure Source: https://github.com/tunnckocore/jsonrpc-v2.0-spec/blob/master/jsonrpc-v2-spec.md Details the structure of a JSON-RPC 2.0 Response object, which servers send back to clients for invoked requests. It must contain either a `result` or an `error` member, along with the original `id`. ```APIDOC JSON-RPC 2.0 Response Object: When a client sends a Request object (that is not a notification), the Server MUST reply with a Response object. Structure: * jsonrpc (String): REQUIRED. Specifies the JSON-RPC protocol version. MUST be exactly "2.0". * result (Any): REQUIRED on success. The value returned by the invoked method. Its type is defined by the method. This member MUST NOT exist if there was an error invoking the method. * error (Object): REQUIRED on error. An Error object (see below). This member MUST NOT exist if there was no error triggered during invocation. * id (String | Number | Null): REQUIRED. MUST be the same value as the `id` in the Request object it's responding to. If detecting the `id` in the Request was impossible (e.g., Parse error), it MUST be `Null`. Exactly one of `result` or `error` MUST be included. Example (Success): { "jsonrpc": "2.0", "result": 19, "id": 1 } Example (Error): { "jsonrpc": "2.0", "error": { "code": -32601, "message": "Method not found" }, "id": "1" } ``` -------------------------------- ### JSON-RPC 2.0 Notification Structure Source: https://github.com/tunnckocore/jsonrpc-v2.0-spec/blob/master/jsonrpc-v2-spec.md Describes a JSON-RPC 2.0 Notification, which is a Request object sent by the client without an `id`. Notifications are used for methods that do not require a response from the server. ```APIDOC JSON-RPC 2.0 Notification: A Request object without an `id` member is a Notification. The Server MUST NOT reply to a Notification. Notifications are for cases where no response is required. Example: { "jsonrpc": "2.0", "method": "update", "params": [1, 2, 3, 4, 5] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.