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

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

curl https://mainnet.helius-rpc.com/?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 https://mainnet.helius-rpc.com/?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.


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

Status
Description

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