Using Solana blockchain nodes

This page describes how to call the Solana node API. Before you can access the Solana blockchain node, you will need to know the API key and node endpoint URL. Follow the using blockchain nodes guide to determine these, if you have not already done so.

JSON-RPC

This section describes querying a Solana blockchain node's JSON-RPC API.

Example RPC

You can query the client using JSON-RPC. See Solana RPC API Reference for documentation.

For example, to call the getBalance method:

curl -H POST \
  -H "X-goog-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "id":1,
    "jsonrpc":"2.0",
    "method": "getBalance",
    "params": ["C8BSJt7GVYZNpkLTM9rHFzh1VQm14bYQPQFS77NSSugG"]
  }' \
  http://YOUR_NODES_URL

Where:

  • id is an identifier set by the client--the originator of the request. For example, 1.
  • jsonrpc is the JSON-RPC version. For example, 2.0.
  • method is the name of the method. For example, getBalance.
  • params are values to be used with method.
  • YOUR_NODES_URL is the address returned in Get the blockchain node URLs. For example, json-rpc.5baqy90l9xcxq6i262vch479a.d.blockchainnodeengine.com.
  • YOUR_API_KEY is the key you created in Create an API key.

See JSON-RPC2.0 Specification for more information on the format of the Request object.

Here's a sample response to the previous command:

{
  "jsonrpc": "2.0",
  "result": {
    "context": {  
      "apiVersion": "1.16.18",
      "slot": 226033962
    },
    "value": 1590137628261212
  },
  "id": 1
}

Private Service Connect port reference guide

Private Service Connect enabled nodes use a user generated static IP address along with the designated port to generate an endpoint. Use the appropriate mapping in the following table.

Port Type Port Number
JSON RPC API Endpoint 8899
Websocket API Endpoint 8900
Client Metrics API Endpoint 8647