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:

  1. Get block, transaction and network information

  2. Get account information

  3. Send and validate transactions

  4. Get estimate of gas and fees

  5. Interact with smart contracts

  6. Monitor network health

NEAR Network Support

Network
API Interface

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.

  1. 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.

  1. Install Axios using this command: Using npm:

    Using yarn:

  2. Create a new file and name it index.js. This is where you will make your first call.

  3. Set ES module "type": "module" in your package.json.

  4. Add the following code to the file (index.js):

    Replace <ACCESS_TOKEN> with your actual access token from GetBlock.

  5. 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.

  1. Set up your project using this command:

  2. Set up a virtual environment to isolate dependencies:

  3. Install the requests library:

  4. Create a new file called main.py and insert the following code:

    Replace <ACCESS_TOKEN> with your actual access token from GetBlock.

  5. Run the script:

Method Grouping

  1. Network Information

    • network_info

    • validators

    • status

  2. Blocks and Transactions

    • block

    • chunk

    • tx

    • broadcast_tx_async

    • broadcast_tx_commit

  3. Contracts

    • call_function

    • query(view_code)

    • query(view_state)

  4. Gas and Fees

    • gas_price

  5. Account

    • query(view_account)

    • query(view_account_basic)

Last updated

Was this helpful?