[...]) and separate them with commas. Each inner request keeps its own method, parameters, and ID, and the server returns the corresponding responses as an array. Notifications still have no response entry.
This page documents nearcore’s query-only contribution to the JSON-RPC 2.0 batch specification. Recent nearcore nodes accept these arrays at the root POST / endpoint when the operator enables them. Batching is enabled by default in nearcore, but providers can disable it.
Only the exact, case-sensitive query method executes in a batch. Other requests that include an ID, including send_tx, broadcast_tx_async, and broadcast_tx_commit, return -32601 (method not found). Submit transactions and call every other RPC method with individual requests.
Public providers can deploy different nearcore versions, disable batching, or apply different limits, gateways, and request policies. Confirm availability, limits, and how a provider accounts for each batch entry before relying on batching.
Consistent block-pinned queries
Entries are independent and may run concurrently. A batch has no execution ordering, is not atomic, and does not automatically read from one snapshot. The server currently preserves response order as an implementation detail, but clients must correlate responses byid.
When the queries must observe the same finalized state, first resolve one final block with an individual block request. Then pass its hash as block_id in every query. This localnet example queries the preconfigured test.near and near accounts and decodes the response array by ID:
IDs and notifications
- String, number, and explicit
nullIDs are echoed in responses. An omittedidmakes the entry a notification; an explicit"id": nulldoes not. - Boolean, array, and object IDs are invalid and receive
-32600with"id": null. - Duplicate IDs are accepted, but make correlation ambiguous. Use a unique ID for every request that expects a response.
- Omitted or
nullparamsare treated as absent. Object and array values reach normal query parsing; other primitive values are invalid and receive-32600. - A
querynotification executes, but the server suppresses its result. A notification for any other method is silently ignored. - A batch containing only valid notifications returns HTTP
204with no body.
-32600 response. They do not prevent valid sibling queries from running.
HTTP behavior and errors
When batching is enabled, a valid, nonempty batch with at least one response entry returns HTTP200, even when individual entries contain RPC errors. Clients must inspect each response’s result or error field.
Malformed JSON and an empty array produce one non-array error response with HTTP
400. A disabled node and the two limit errors also replace the batch with one non-array response whose ID is null and HTTP 200.
Validation uses this order: unsupported content type (415), oversized HTTP body (413), malformed or trailing JSON (-32700), unchanged handling for a non-array request, empty array (-32600), disabled batching (-32005), and too many entries (-32010). Entries execute only after all of these checks pass.
Node limits
Node operators configure batching underrpc in config.json:
The fields have backward-compatible defaults when omitted. Changing one requires restarting the node.
The concurrency setting is not a node-wide admission limit. Simultaneous batches can multiply outstanding work, and individual RPC requests are not counted against it. A gateway that charges only per HTTP request will undercount batch work. Operators should charge every top-level entry, including notifications, and ideally account for query type or cost. If a gateway cannot inspect arrays, combine a conservative batch-size limit with connection and HTTP-request rate limits.
There is no deadline around a whole batch. Individual operations keep their existing timeout behavior, and disconnecting does not guarantee that work already queued by the node will stop. The response-size limit bounds only the serialized responses retained for the aggregate; it does not bound query compute, queue depth, or transient memory used while admitted query parameters are decoded or an individual result is produced.
Self-hosted nodes expose
near_rpc_batch_requests_total, near_rpc_batch_request_entries, near_rpc_batch_entries_total, near_rpc_batch_processing_time, near_rpc_batch_response_size_bytes, near_rpc_batch_requests_in_flight, and near_rpc_batch_query_entries_in_flight at /metrics. These fixed-cardinality series separate batch-envelope behavior from the existing per-method metrics; the response-size histogram observes successful response arrays. Processing-time and in-flight measurements begin after the batch passes syntax, kill-switch, and size-limit admission checks.