🔗HTTP
Solana nodes accept HTTP requests using the JSON-RPC 2.0 specification.
Info
For JavaScript applications, use the
@solana/web3.js
library as a convenient interface for the RPC methods to interact with a Solana node.For a PubSub connection to a Solana node, use the WebSocket API.
Request Formatting
To make a JSON-RPC request, send an HTTP POST request with a Content-Type: application/json
header. The JSON request data should contain the following fields:
jsonrpc
string
Set to "2.0"
.
id
string | number
A unique identifier for the request, generated by the client. Can be a string, number, or null
.
method
string
The name of the method to invoke.
params
array
A JSON array of ordered parameter values.
Example Request using cURL
Response Format
The response will be a JSON object with the following fields:
jsonrpc
string
Matches the request specification.
id
number
Matches the request identifier.
result
array|number|object|string
Requested data or success confirmation.
Batch Requests
Requests can be sent in batches by sending an array of JSON-RPC request objects in a single POST request.
Example Request with Commitment
The commitment
parameter should be included as the last element in the params
array:
Definitions
Hash: A SHA-256 hash of a chunk of data.
Pubkey: The public key of an Ed25519 key-pair.
Transaction: A list of Solana instructions signed by a client keypair to authorize those actions.
Signature: An Ed25519 signature of a transaction's payload data, including instructions. This can be used to identify transactions.
Health Check
Although not part of the JSON-RPC API, a GET /health
request at the RPC HTTP endpoint provides a health-check mechanism for load balancers or other network infrastructure.
Response Codes
ok
The node is within HEALTH_CHECK_SLOT_DISTANCE
slots of the latest cluster confirmed slot.
behind { distance }
The node is behind by distance
slots from the latest cluster confirmed slot.
unknown
The node is unable to determine its status relative to the cluster.
Example health check response body:
ok
behind { distance }
unknown
Last updated