Setup
In order to use the RPC API you will need to setup the correct RPC endpoints.
RPC Endpoint Setup
POST
for all methodsJSON RPC 2.0
id: "dontcare"
endpoint URL varies by network:
mainnet
https://rpc.mainnet.near.org
testnet
https://near.nownodes.io/{API_KEY}
betanet
https://rpc.betanet.near.org
(may be unstable)localnet
http://localhost:3030
Limits
Maximum number of requests per IP: 600 req/min
Querying Historical Data
Querying historical data (older than 5 epochs or ~2.5 days), you may get responses that the data is not available anymore. In that case, archival RPC nodes will come to your rescue:
mainnet
https://archival-rpc.mainnet.near.org
testnet
https://archival-rpc.testnet.near.org
Limits
Maximum number of requests per IP: 600 req/min
Postman Setup
Make sure you add a header with a key of
Content-Type
and value ofapplication/json
.Then select the
Body
tab and choose theraw
radio button and ensureJSON
is the selected format.
After that is set up, just copy/paste the JSON object
example snippets below into the body
of your request, on Postman, and click send
.
JavaScript Setup
For
near-api-js
installation and setup please refer tonear-api-js
quick reference documentation.All JavaScript code snippets require a
near
object. For examples of how to instantiate, click here.
HTTPie Setup
Using block_id
param
block_id
paramThe block_id
param can take either the block number (e.g. 27912554
) or the block hash (e.g. '3Xz2wM9rigMXzA2c5vgCP8wTgFBaePucgUmVYPkMqhRL'
) as an argument.
:::caution
:::
Using finality
param
finality
paramThe finality
param has two options: optimistic
and final
.
optimistic
uses the latest block recorded on the node that responded to your query (< 1 second delay after the transaction is submitted)final
is for a block that has been validated on at least 66% of the nodes in the network (usually takes 2 blocks / approx. 2 second delay)