Generated Rust types and async client for the NEAR Protocol JSON-RPC API, built directly from NEAR's official OpenRPC specification.
use near_openrpc_client::{NearRpcClient, types::*};
#[tokio::main]
async fn main() -> near_openrpc_client::client::Result<()> {
let client = NearRpcClient::mainnet();
// Get node status
let status = client.status().await?;
println!("Chain: {} at block {}", status.chain_id, status.sync_info.latest_block_height);
// View an account
let account = client.view_account(RpcViewAccountRequest::FinalityAccountId {
account_id: "near".parse().unwrap(),
finality: Finality::Final,
}).await?;
println!("Balance: {}", account.amount);
Ok(())
}- 200+ strongly-typed structs generated from the OpenRPC schema via
typify - Async client with convenience constructors for mainnet/testnet/betanet/local
- Types-only mode — disable the
clientfeature to use just the types with noreqwest/tokiodependency
# Full client (default)
near-openrpc-client = "0.1"
# Types only
near-openrpc-client = { version = "0.1", default-features = false }At build time, build.rs reads openrpc.json, converts it to a JSON Schema, and feeds it to typify to generate src/generated.rs.
A daily GitHub Action fetches the latest spec from nearcore and opens a PR if anything changed.
cargo run --example mainnetMIT OR Apache-2.0