Solana RPC HTTP Methods
Solana nodes accept HTTP requests using the JSON-RPC 2.0 specification.
For JavaScript applications, use the @solana/web3.js library as a convenient interface for the RPC methods to interact with a Solana node. For an PubSub connection to a Solana node, use the Websocket API.
RPC HTTP Endpoint #
Default port: 8899
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 4
fields:
jsonrpc: <string>
- set to"2.0"
id: <number>
- a unique client-generated identifying integermethod: <string>
- a string containing the method to be invokedparams: <array>
- a JSON array of ordered parameter values
Example using curl:
curl https://api.devnet.solana.com -s -X POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getBalance",
"params": [
"83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri"
]
}
'
The response output will be a JSON object with the following fields:
jsonrpc: <string>
- matching the request specificationid: <number>
- matching the request identifierresult: <array|number|object|string>
- requested data or success confirmation
Requests can be sent in batches by sending an array of JSON-RPC request objects as the data for a single POST.
Example Request #
The commitment parameter should be included as the last element in the params
array:
curl https://api.devnet.solana.com -s -X POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getBalance",
"params": [
"83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri",
{
"commitment": "finalized"
}
]
}
'
Definitions #
- Hash: A SHA-256 hash of a chunk of data.
- Pubkey: The public key of a Ed25519 key-pair.
- Transaction: A list of Solana instructions signed by a client keypair to authorize those actions.
- Signature: An Ed25519 signature of transaction's payload data including instructions. This can be used to identify transactions.
Health Check #
Although not a JSON RPC API, a GET /health
at the RPC HTTP Endpoint provides a
health-check mechanism for use by load balancers or other network
infrastructure. This request will always return a HTTP 200 OK response with a
body of "ok", "behind" or "unknown":
ok
: The node is withinHEALTH_CHECK_SLOT_DISTANCE
slots from the latest cluster confirmed slotbehind { distance }
: The node is behinddistance
slots from the latest cluster confirmed slot wheredistance {'>'} HEALTH_CHECK_SLOT_DISTANCE
unknown
: The node is unable to determine where it stands in relation to the cluster