Skip to main content

rpc_methods - JSON-RPC Method

Description​

Returns a list of all available JSON-RPC methods that the Polkadot node supports. This method is useful for discovering API capabilities, checking method availability, and debugging connectivity issues.

Parameters​

This method does not require any parameters.

Returns​

FieldTypeDescription
methodsarrayArray of strings listing all available RPC method names

Request Example​

{
"jsonrpc": "2.0",
"method": "rpc_methods",
"params": [],
"id": 1
}

Response Example​

{
"jsonrpc": "2.0",
"result": {
"methods": [
"author_pendingExtrinsics",
"author_submitAndWatchExtrinsic",
"author_submitExtrinsic",
"author_unwatchExtrinsic",
"beefy_getFinalizedHead",
"beefy_subscribeJustifications",
"beefy_unsubscribeJustifications",
"chain_getBlock",
"chain_getBlockHash",
"chain_getFinalizedHead",
"chain_getHeader",
"chain_subscribeAllHeads",
"chain_subscribeFinalizedHeads",
"chain_subscribeNewHeads",
"chain_subscribeRuntimeVersion",
"chain_unsubscribeAllHeads",
"chain_unsubscribeFinalizedHeads",
"chain_unsubscribeNewHeads",
"chain_unsubscribeRuntimeVersion",
"childstate_getKeys",
"childstate_getKeysPaged",
"childstate_getStorage",
"childstate_getStorageEntries",
"childstate_getStorageHash",
"childstate_getStorageSize",
"grandpa_proveFinality",
"grandpa_roundState",
"grandpa_subscribeJustifications",
"grandpa_unsubscribeJustifications",
"offchain_localStorageGet",
"offchain_localStorageSet",
"payment_queryFeeDetails",
"payment_queryInfo",
"rpc_methods",
"state_call",
"state_getChildReadProof",
"state_getKeysPaged",
"state_getMetadata",
"state_getPairs",
"state_getReadProof",
"state_getRuntimeVersion",
"state_getStorage",
"state_getStorageHash",
"state_getStorageSize",
"state_queryStorage",
"state_queryStorageAt",
"state_subscribeRuntimeVersion",
"state_subscribeStorage",
"state_traceBlock",
"state_trieMigrationStatus",
"state_unsubscribeRuntimeVersion",
"state_unsubscribeStorage",
"sync_state_genSyncSpec",
"system_accountNextIndex",
"system_addReservedPeer",
"system_chain",
"system_chainType",
"system_dryRun",
"system_health",
"system_localListenAddresses",
"system_localPeerId",
"system_name",
"system_nodeRoles",
"system_peers",
"system_properties",
"system_removeReservedPeer",
"system_syncState",
"system_version"
]
},
"id": 1
}

Code Examples​

JavaScript​

const getAvailableMethods = async () => {
const response = await fetch('https://api-polkadot.n.dwellir.com', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
jsonrpc: '2.0',
method: 'rpc_methods',
params: [],
id: 1
})
});

const data = await response.json();
return data.result.methods;
};

// Check available methods
const methods = await getAvailableMethods();
console.log(`Total methods available: ${methods.length}`);

// Group methods by namespace
const methodsByNamespace = methods.reduce((acc, method) => {
const [namespace] = method.split('_');
if (!acc[namespace]) acc[namespace] = [];
acc[namespace].push(method);
return acc;
}, {});

console.log('Methods by namespace:', methodsByNamespace);

// Check if specific method is available
const hasMethod = (methodName) => methods.includes(methodName);
console.log('Has author_submitExtrinsic:', hasMethod('author_submitExtrinsic'));

Python​

import requests
import json
from collections import defaultdict

def get_rpc_methods():
url = "https://api-polkadot.n.dwellir.com"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}

payload = {
"jsonrpc": "2.0",
"method": "rpc_methods",
"params": [],
"id": 1
}

response = requests.post(url, headers=headers, data=json.dumps(payload))
data = response.json()

if "error" in data:
raise Exception(f"RPC Error: {data['error']}")

return data["result"]["methods"]

# Get and analyze methods
methods = get_rpc_methods()
print(f"Total methods: {len(methods)}")

# Group by namespace
namespaces = defaultdict(list)
for method in methods:
namespace = method.split('_')[0]
namespaces[namespace].append(method)

# Display namespace summary
for namespace, methods_list in sorted(namespaces.items()):
print(f"{namespace}: {len(methods_list)} methods")

# Check for specific capabilities
subscription_methods = [m for m in methods if 'subscribe' in m]
print(f"\nSubscription methods: {len(subscription_methods)}")

Method Categories​

Core Namespaces​

NamespaceDescriptionExample Methods
authorTransaction submissionsubmitExtrinsic, pendingExtrinsics
chainBlockchain queriesgetBlock, getBlockHash
stateState queriesgetStorage, getMetadata
systemNode informationhealth, version, chain

Specialized Namespaces​

NamespaceDescriptionExample Methods
beefyBEEFY consensusgetFinalizedHead
grandpaGRANDPA finalityroundState, proveFinality
childstateChild trie queriesgetStorage, getKeys
paymentFee calculationqueryInfo, queryFeeDetails
offchainOffchain storagelocalStorageGet, localStorageSet
syncSync operationsstate_genSyncSpec

Method Availability Check​

class RPCCapabilities {
constructor(methods) {
this.methods = new Set(methods);
this.namespaces = this.groupByNamespace(methods);
}

groupByNamespace(methods) {
const namespaces = {};
methods.forEach(method => {
const [ns] = method.split('_');
if (!namespaces[ns]) namespaces[ns] = new Set();
namespaces[ns].add(method);
});
return namespaces;
}

hasMethod(method) {
return this.methods.has(method);
}

hasNamespace(namespace) {
return namespace in this.namespaces;
}

requireMethods(required) {
const missing = required.filter(m => !this.hasMethod(m));
if (missing.length > 0) {
throw new Error(`Missing required methods: ${missing.join(', ')}`);
}
return true;
}

getSubscriptionMethods() {
return Array.from(this.methods).filter(m =>
m.includes('subscribe') || m.includes('unsubscribe')
);
}

supportsWebSocket() {
return this.getSubscriptionMethods().length > 0;
}
}

// Usage
const methods = await getAvailableMethods();
const capabilities = new RPCCapabilities(methods);

// Check capabilities
console.log('Supports WebSocket:', capabilities.supportsWebSocket());
console.log('Has GRANDPA:', capabilities.hasNamespace('grandpa'));

// Require specific methods
try {
capabilities.requireMethods([
'chain_getBlock',
'author_submitExtrinsic',
'state_getMetadata'
]);
console.log('All required methods available');
} catch (error) {
console.error(error.message);
}

Use Cases​

  1. API Discovery: Explore available functionality
  2. Capability Detection: Check if specific features are available
  3. Version Compatibility: Verify method availability across versions
  4. Client Configuration: Configure clients based on available methods
  5. Documentation: Generate API documentation dynamically

Notes​

  • Method list may vary based on node configuration
  • Some methods require specific node flags to be enabled
  • Subscription methods only work over WebSocket connections
  • Custom chains may have additional or different methods
  • Use this to verify node capabilities before making calls