Getting Started
From zero to your first on-chain query in under 5 minutes. No infrastructure, no config files — just an API key and one npm install.
Add the KuberNodes SDK to your project. Both package names work — kubernodes is the recommended entry point.
npm install kubernodespnpm add kubernodesyarn add kubernodesnpm install @kubernodes/sdk # same package, scoped nameCreate a free account and copy your key from the dashboard.
# https://app.kubernodes.com → API Keys → Create
pk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxQuery the latest block number on Ethereum mainnet.
import { Kuber } from 'kubernodes';
// One-liner — defaults to Ethereum mainnet
const kuber = new Kuber(process.env.KUBERNODES_API_KEY!);
const block = await kuber.getBlockNumber();
console.log('Latest block:', block); // e.g. 22_100_417const { Kuber } = require('kubernodes');
const kuber = new Kuber(process.env.KUBERNODES_API_KEY);
const block = await kuber.getBlockNumber();
console.log('Latest block:', block);// Advanced: fine-grained config (same underlying client)
import { createClient, CHAINS } from 'kubernodes';
const kn = createClient({
apiKey: process.env.KUBERNODES_API_KEY!,
chainId: CHAINS.ETHEREUM.chainId,
retries: 3,
timeout: 30_000,
});curl https://rpc.kubernodes.com/eth \
-X POST \
-H "Content-Type: application/json" \
-H "X-API-Key: pk_live_YOUR_KEY" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'All standard eth_* methods work. Common helpers:
// Get native balance
const wei = await kuber.getBalance('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045');
const eth = Number(wei) / 1e18;
console.log(`Balance: ${eth} ETH`);
// Get gas price
const gwei = Number(await kuber.getGasPrice()) / 1e9;
console.log(`Gas: ${gwei.toFixed(2)} gwei`);
// Get block with transactions
const block = await kuber.getBlock('latest', true);
console.log(`Txs in block: ${block.transactions.length}`);
// Get ERC-20 token balances (batch)
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
const USDT = '0xdAC17F958D2ee523a2206206994597C13D831ec7';
const balances = await kuber.getTokenBalances(
'0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
[USDC, USDT],
);
balances.forEach(b => console.log(b.token, b.balance));Pass a chainId per-call, use chain-bound clients, or create separate Kuber instances.
import { Kuber, CHAINS } from 'kubernodes';
const kuber = new Kuber(process.env.KUBERNODES_API_KEY!);
// Option A: pass chainId per-call
const arbBlock = await kuber.getBlockNumber(CHAINS.ARB_ONE.chainId);
// Option B: chain-bound client (cleaner)
const base = kuber.chain(CHAINS.BASE.chainId);
const baseGas = await base.getGasPrice();
console.log('Base gas:', Number(baseGas) / 1e9, 'gwei');
// Option C: one Kuber per chain
const polygon = new Kuber(process.env.KUBERNODES_API_KEY!, CHAINS.POLYGON.chainId);
const maticBlock = await polygon.getBlockNumber();