🔗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:

Field
Type

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.

The name of the method to invoke.

A JSON array of ordered parameter values.


Example Request using cURL

curl http://srpc.solapi.pro/?api_key=<api-key> -s -X POST -H "Content-Type: application/json" -d '
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getBalance",
    "params": [
      "83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri"
    ]
  }
'

Response Format

The response will be a JSON object with the following fields:

Field
Type
Description

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:

curl http://srpc.solapi.pro/?api_key=<api-key> -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 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.

Last updated