- Create and manage NEAR accounts
- Call functions on smart contracts
- Transfer tokens, including native NEAR, Fungible Tokens, Non-Fungible Tokens
- Sign transactions/meta-transactions/messages and broadcasting them to the network
- Deploy smart contracts
Available APIs
We have APIs available for Javascript, Rust, and Python. Add them to your project using the following commands:- 🌐 near-api-js
- 🌐 near-kit
- 🦀 near-api-rs
- 🐍 py-near
Account
Get Balance
Gets the available and staked balance of an account in yoctoNEAR.- 🌐 near-api-js
- 🌐 near-kit
- 🦀 near-api-rs
- 🐍 py-near
Get State
Get basic account information, such as its code hash and storage usage.- 🌐 near-api-js
- 🌐 near-kit
- 🦀 near-api-rs
- 🐍 py-near
Create Named Account
To create a named account likeuser.testnet, you need to call the create_account function on near (or testnet), passing as parameters the new account ID, and a public key to add as FullAccess key.
- 🌐 near-api-js
- 🌐 near-kit
- 🦀 near-api-rs
- 🐍 py-near
Create Sub-Account
Accounts on NEAR can create sub-accounts under their own namespace, which is useful for organizing accounts by purpose — for example,project.user.testnet.
- 🌐 near-api-js
- 🌐 near-kit
- 🦀 near-api-rs
- 🐍 py-near
Parent accounts have no control over their sub-accounts, they are completely independent.
Delete Account
Accounts on NEAR can delete themselves, transferring any remaining balance to a specified beneficiary account.- 🌐 near-api-js
- 🌐 near-kit
- 🦀 near-api-rs
Deleting an account DOES NOT affect its sub-accounts - they will remain active.
The Beneficiary Only Receives NEAR TokensFungible (FTs) or Non-Fungible tokens (NFTs) held by the account ARE NOT automatically transferred. These tokens are still associated with the account, even after the account is deleted. Make sure to transfer those assets manually before deletion, or you’re risking losing them permanently. Once the account is gone, those assets are effectively stuck unless the same account is recreated by anyone (not necessarily you).
Make Sure the Beneficiary Account ExistsIf the beneficiary account doesn’t exist, all NEAR tokens sent to it will be burned. Double-check the account ID before proceeding.
Transactions
Send Tokens
Accounts can transfer different types of tokens to other accounts, including the native NEAR token and NEP-141 fungible tokens.- 🌐 near-api-js
- 🌐 near-kit
- 🦀 near-api-rs
- 🐍 py-near
Call Function
A smart contract exposes its methods, and making a function call that modifies state requires aSigner/KeyPair. You can optionally attach a NEAR deposit to the call.
- 🌐 near-api-js
- 🌐 near-kit
- 🦀 near-api-rs
- 🐍 py-near
- function call
- typed contract
Batch Actions
You can send multiple actions in a batch to a single receiver. If one action fails then the entire batch of actions will be reverted.- 🌐 near-api-js
- 🌐 near-kit
- 🦀 near-api-rs
Simultaneous Transactions
The only way to have true simultaneous transactions is to use multiple access keys on a same account. Each access key maintains its own nonce, allowing transactions signed with different keys to be processed in parallel:- 🌐 near-api-js
- 🌐 near-kit
- 🦀 near-api-rs
- 🐍 py-near
Deploy a Contract
On NEAR, a smart contract is deployed as a WASM file. Every account has the potential to become a contract — you simply need to deploy code to it.- 🌐 near-api-js
- 🌐 near-kit
- 🦀 near-api-rs
- 🐍 py-near
Deploy a Global Contract
Global contracts allow smart contracts to be deployed once and reused by any account without incurring high storage costs. There are two ways to reference a global contract:- By account: The contract code is tied to another account.
- By hash: You reference the contract by its immutable code hash.
- 🌐 near-api-js
- 🌐 near-kit
- 🦀 near-api-rs
- by account
- by hash
Use a Global Contract
Once a global contract has been deployed, here is how you can reference and use it from another account.- 🌐 near-api-js
- 🌐 near-kit
- 🦀 near-api-rs
- by account
- by hash
View Function
View functions are read-only methods on a smart contract that do not modify state. You can call them without using an account or signing a transaction.- 🌐 near-api-js
- 🌐 near-kit
- 🦀 near-api-rs
- 🐍 py-near
Keys
Get All Access Keys
- 🌐 near-api-js
- 🦀 near-api-rs
- 🐍 py-near
Add Full Access Key
A Full Access key grants complete control over the account. Anyone with this key can transfer funds, sign transactions, interact with contracts, or even delete the account entirely.- 🌐 near-api-js
- 🌐 near-kit
- 🦀 near-api-rs
- 🐍 py-near
Add Function Call Key
A Function Call access key is designed specifically to sign transactions that include onlyfunctionCall actions to a specific contract.
You can further restrict this key by:
- Limiting which method names can be called
- Capping the amount of
NEARthe key can spend on transaction fees
- 🌐 near-api-js
- 🌐 near-kit
- 🦀 near-api-rs
- 🐍 py-near
Delete Access Key
Accounts on NEAR can delete their own keys.- 🌐 near-api-js
- 🌐 near-kit
- 🦀 near-api-rs
- 🐍 py-near
Be very careful when deleting keys. Removing all keys from an account will cause you to lose access to the account permanently.
Validate Message Signatures
Users can sign messages using thewallet-selector signMessage method, which returns a signature. This signature can be verified using the following code:
- 🌐 near-api-js
- 🌐 near-kit
Additional resources
- 🌐 near-api-js
- 🌐 near-kit
- 🦀 near-api-rs
- 🐍 py-near