11---
22title : Runtime API Calls
3- description : Learn how to call runtime APIs on Polkadot using PAPI, Polkadot.js, Dedot, Python Substrate Interface , and Subxt.
3+ description : Learn how to call Polkadot runtime APIs to access the Wasm runtime and retrieve computed results using PAPI, Polkadot.js, Dedot, Python, and Subxt.
44categories : Chain Interactions
55---
66
@@ -12,23 +12,23 @@ Polkadot SDK runtime APIs provide direct access to the blockchain's WebAssembly
1212
1313Common runtime APIs include:
1414
15- - ** AccountNonceApi** - retrieves the current transaction nonce for an account
16- - ** Metadata** - queries available metadata versions and runtime information
17- - ** TransactionPaymentApi** - estimates transaction fees before submission
18- - ** NominationPoolsApi** - retrieves staking pool information and pending rewards
19- - ** StakingApi** - accesses staking-related computations
15+ - ** AccountNonceApi** : Retrieves the current transaction nonce for an account.
16+ - ** Metadata** : Queries available metadata versions and runtime information.
17+ - ** TransactionPaymentApi** : Estimates transaction fees before submission.
18+ - ** NominationPoolsApi** : Retrieves staking pool information and pending rewards.
19+ - ** StakingApi** : Accesses staking-related computations.
2020
21- This guide demonstrates how to call runtime APIs using five popular SDKs:
21+ ## Call Runtime APIs
2222
23- - ** [ Polkadot API (PAPI)] ( /reference/tools/papi/ ) {target=\_ blank}** - modern TypeScript library with type-safe APIs
24- - ** [ Polkadot.js API] ( /reference/tools/polkadot-js-api/ ) {target=\_ blank}** - comprehensive JavaScript library (maintenance mode)
25- - ** [ Dedot] ( /reference/tools/dedot/ ) {target=\_ blank}** - lightweight TypeScript library optimized for performance
26- - ** [ Python Substrate Interface] ( /reference/tools/py-substrate-interface/ ) {target=\_ blank}** - Python library for Substrate chains
27- - ** [ Subxt] ( /reference/tools/subxt/ ) {target=\_ blank}** - Rust library with compile-time type safety
23+ This section demonstrates how to call runtime APIs using the following SDKs:
2824
29- Select your preferred SDK below to see complete, runnable examples that query Polkadot Hub TestNet for account nonces and metadata information.
25+ - ** Polkadot API (PAPI)** : Modern TypeScript library with type-safe APIs.
26+ - ** Polkadot.js API** : Comprehensive JavaScript library (maintenance mode).
27+ - ** Dedot** : Lightweight TypeScript library optimized for performance.
28+ - ** Python Substrate Interface** : Python library for Substrate chains.
29+ - ** Subxt** : Rust library with compile-time type safety.
3030
31- ## Call Runtime APIs
31+ Select your preferred SDK below to see complete, runnable examples that query Polkadot Hub TestNet for account nonces and metadata information.
3232
3333=== "PAPI"
3434
@@ -63,8 +63,8 @@ Select your preferred SDK below to see complete, runnable examples that query Po
6363
6464 The following example demonstrates calling several runtime APIs:
6565
66- - `AccountNonceApi.account_nonce` - gets the current nonce for an account
67- - `Metadata.metadata_versions` - retrieves supported metadata versions
66+ - ** `AccountNonceApi.account_nonce`**: Gets the current nonce for an account.
67+ - ** `Metadata.metadata_versions`**: Retrieves supported metadata versions.
6868
6969 Create a file named `runtime-apis.ts` and add the following code:
7070
@@ -113,8 +113,8 @@ Select your preferred SDK below to see complete, runnable examples that query Po
113113
114114 The following example demonstrates calling several runtime APIs:
115115
116- - `accountNonceApi.accountNonce` - gets the current nonce for an account
117- - `metadata.metadataVersions` - retrieves supported metadata versions
116+ - ** `accountNonceApi.accountNonce`**: Gets the current nonce for an account.
117+ - ** `metadata.metadataVersions`**: Retrieves supported metadata versions.
118118
119119 Create a file named `runtime-apis.js` and add the following code:
120120
@@ -161,8 +161,8 @@ Select your preferred SDK below to see complete, runnable examples that query Po
161161
162162 The following example demonstrates calling several runtime APIs:
163163
164- - `accountNonceApi.accountNonce` - gets the current nonce for an account
165- - `metadata.metadataVersions` - retrieves supported metadata versions
164+ - ** `accountNonceApi.accountNonce`**: Gets the current nonce for an account.
165+ - ** `metadata.metadataVersions`**: Retrieves supported metadata versions.
166166
167167 Create a file named `runtime-apis.ts` and add the following code:
168168
@@ -208,8 +208,8 @@ Select your preferred SDK below to see complete, runnable examples that query Po
208208
209209 The following example demonstrates calling several runtime APIs:
210210
211- - `AccountNonceApi.account_nonce` - gets the current nonce for an account
212- - `Core.version` - retrieves runtime version information
211+ - ** `AccountNonceApi.account_nonce`**: Gets the current nonce for an account.
212+ - ** `Core.version`**: Retrieves runtime version information.
213213
214214 Create a file named `runtime_apis.py` and add the following code:
215215
@@ -270,8 +270,8 @@ Select your preferred SDK below to see complete, runnable examples that query Po
270270
271271 The following example demonstrates calling several runtime APIs:
272272
273- - `AccountNonceApi.account_nonce` - gets the current nonce using the static interface
274- - `Metadata.metadata_versions` - retrieves supported metadata versions using the dynamic interface
273+ - ** `AccountNonceApi.account_nonce`**: Gets the current nonce using the static interface.
274+ - ** `Metadata.metadata_versions`**: Retrieves supported metadata versions using the dynamic interface.
275275
276276 Create a file at `src/bin/runtime_apis.rs` and add the following code:
277277
@@ -316,22 +316,32 @@ The following runtime APIs are commonly available on Polkadot SDK-based chains:
316316
317317## Where to Go Next
318318
319+ Now that you understand how to call runtime APIs to execute logic within the runtime, explore these related topics:
320+
319321<div class =" grid cards " markdown >
320322
321- - < span class = " badge guide " >Guide</ span > ** Query On-Chain State **
323+ - __ Query with SDKs __
322324
323325 ---
324326
325- Learn how to query storage data from the blockchain .
327+ Use TypeScript, Python, or Rust SDKs for programmatic access .
326328
327329 [ :octicons-arrow-right-24: Get Started] ( /chain-interactions/query-data/query-sdks/ )
328330
329- - <span class =" badge guide " >Guide</span > ** Send Transactions**
331+ - __ Query On-Chain State with Sidecar REST API__
332+
333+ ---
334+
335+ Learn how to query on-chain state using the Sidecar REST API
336+
337+ [ :octicons-arrow-right-24: Get Started] ( /chain-interactions/query-data/query-rest.md )
338+
339+ - __ Send Transactions__
330340
331341 ---
332342
333- Learn how to construct and submit transactions.
343+ Learn to construct and submit transactions.
334344
335- [ :octicons-arrow-right-24: Get Started] ( /chain-interactions/send-transactions/with-sdks/ )
345+ [ :octicons-arrow-right-24: Get Started] ( /chain-interactions/send-transactions/with-sdks )
336346
337- </div >
347+ </div >
0 commit comments