Skip to main content

Getting Started with the RPC API

The Avalanche RPC API provides direct access to the Platform Chain (P-Chain) and Exchange Chain (X-Chain) through JSON-RPC 2.0 endpoints. This guide will help you make your first RPC calls to interact with Avalanche’s core chains.

Prerequisites

  • Basic understanding of JSON-RPC
  • A tool for making HTTP requests (curl, Postman, or any programming language with HTTP support)
  • Access to an Avalanche node endpoint

Making Your First RPC Call

All RPC calls follow the standard JSON-RPC 2.0 format. Here’s an example to get the current height of the P-Chain:
curl -X POST https://api.avax.network/ext/bc/P \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "platform.getHeight",
    "params": {},
    "id": 1
  }'

Response Format

All responses follow the JSON-RPC 2.0 standard:
{
  "jsonrpc": "2.0",
  "result": {
    "height": "12345678"
  },
  "id": 1
}

Common Use Cases

The RPC API enables you to:
  • Query Validators: Get information about current validators and their stakes
  • Monitor Staking: Track staking rewards and delegation details
  • Manage Subnets: Create and manage custom blockchain networks
  • Access Blocks: Retrieve block data by height or hash
  • Track Transactions: Query transaction status and details

Next Steps

I