Rust, Python & mobile clients
NEAR client libraries beyond JavaScript: near-api-rs, near-jsonrpc-client-rs, py-near and the Swift and Kotlin JSON-RPC clients — official vs community.
Intermediate4 min read3-question check
Every NEAR client ultimately speaks the same JSON-RPC API, so you can always fall back to plain HTTP. The libraries below save you from hand-encoding Borsh transactions, signing and nonce handling. Pay attention to the Status column: some long-lived names are archived.
Rust#
| Library | Language | Status | What it’s for | Link |
|---|---|---|---|---|
| near-api (near-api-rs) | Rust | Official | High-level, builder-style API inspired by near-cli-rs: accounts, contract deploy and calls, NEAR/FT/NFT transfers, storage deposits, staking, signing via secret key, seed phrase, Ledger or OS keychain, and key pools to avoid nonce clashes. | near/near-api-rs · docs.rs |
| near-jsonrpc-client | Rust | Official | Lower-level typed wrapper over each RPC method (methods::tx, methods::query, …). Use it when you need exact control of requests, e.g. inside indexers or infra. | near/near-jsonrpc-client-rs |
Rust
use near_api::*;
use std::str::FromStr;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let bob = AccountId::from_str("bob.testnet")?;
let balance = Tokens::account(bob)
.near_balance()
.fetch_from_testnet()
.await?;
println!("{balance:?}");
Ok(())
}Python, Swift, Kotlin and others#
| Library | Language | Status | What it’s for | Link |
|---|---|---|---|---|
| py-near | Python | Community (listed on docs.near.org) | Async client: accounts, transfers, contract calls, plus built-in NEAR Intents (OmniBalance) and HOT Protocol helpers. Install with pip install py-near. | pvolnov/py-near · docs |
| near-jsonrpc-client-swift | Swift (iOS 13+, macOS) | Under the near org | Type-safe async/await JSON-RPC client generated from NEAR’s OpenAPI spec; Swift Package Manager. | near/near-jsonrpc-client-swift |
| near-jsonrpc-client-kotlin | Kotlin Multiplatform (Android, iOS) | Under the near org | Coroutine-based typed JSON-RPC client generated from the OpenAPI spec with kotlinx.serialization. | near/near-jsonrpc-client-kotlin |
| near-api-swift / near-api-kotlin | Swift / Kotlin | Legacy | Older mobile SDKs built around the web-wallet redirect login flow. Prefer the JSON-RPC clients above plus your own key management for new apps. | near-api-swift · near-api-kotlin |
Check yourself
3 questions · progress saved in this browser