NEAR Protocol (NEAR)
NEAR Protocol API Reference for seamless interaction with NEAR nodes, enabling scalable, developer-friendly, decentralised applications with low fees and fast transaction finality.
NEAR Protocol is a developer-friendly Layer 1 blockchain built to make decentralised applications (dApps) fast, user-friendly, and scalable.
It uses a Proof of Stake (PoS) consensus mechanism to validate transactions while sharding the network into smaller pieces that work in parallel. This design allows NEAR to process transactions quickly and efficiently with low fees.
Smart contracts on NEAR can be written in:
Beyond just being a blockchain, NEAR is also a platform for AI agents. Its vision is to create a future of User-Owned AI, where artificial intelligence and autonomous agents serve their users — not corporations.
You can do the following with NEAR Protocol API:
Get block, transaction and network information
Get account information
Send and validate transactions
Get estimate of gas and fees
Interact with smart contracts
Monitor network health
NEAR Network Support
Mainnet
JSON RPC
Each method will provide you with the following:
Clear description of functionality and use cases
Required input parameters
Sample requests and responses
Supported network
Code example
Integration
Quickstart
In this section, you will learn how to make your first call with either:
Axios
Python
Quickstart with Axios
Before you begin, you must have already installed npm or yarn on your local machine. If not, check out npm or yarn.
Set up your project using this command:
For npm:
Or yarn:
This creates a project directory named near-api-quickstart and initialises a Node.js project within it.
Install Axios using this command: Using npm:
Using yarn:
Create a new file and name it
index.js. This is where you will make your first call.Set ES module
"type": "module"in yourpackage.json.Add the following code to the file (
index.js):Replace
<ACCESS_TOKEN>with your actual access token from GetBlock.Run the script:
The current gas price will log in the console like this:
Quickstart with Python and Requests
Before you begin, you must have installed Python and Pip on your local machine.
Set up your project using this command:
Set up a virtual environment to isolate dependencies:
Install the requests library:
Create a new file called
main.pyand insert the following code:Replace
<ACCESS_TOKEN>with your actual access token from GetBlock.Run the script:
Method Grouping
Network Information
network_info
validators
status
Blocks and Transactions
block
chunk
tx
broadcast_tx_async
broadcast_tx_commit
Contracts
call_function
query(view_code)
query(view_state)
Gas and Fees
gas_price
Account
query(view_account)
query(view_account_basic)
Last updated
Was this helpful?