Near mainnet api: Error Block Missing (unavailable on the node)

145 Views Asked by At

I was testing near apis and only a few endpoints are working as expected.
https://rpc.mainnet.near.org

I was trying to fetch the block by id and it was throwing this error.

{
    "jsonrpc": "2.0",
    "error": {
        "code": -32000,
        "message": "Server error",
        "data": "Block Missing (unavailable on the node): BBht2EZwfrGrucZKUuW91tMctfE3rMsUQJcFSduTRCGR \n Cause: Unknown"
    },
    "id": "dontcare"
}

The final block call is working and it is even working for few 50 blocks back but for old blocks it is throwing above error.
Is there any range of blocks this api supports?
Can I rely on this api to fetch historical data?

curl request

curl --location --request POST 'https://rpc.mainnet.near.org' --header 'Content-Type: application/json' --data-raw '{
  "jsonrpc": "2.0",
  "id": "dontcare",
  "method": "block",
  "params": {
    "block_id": 33929500
  }
}'
1

There are 1 best solutions below

0
On

This block was garbage collected. Regular nodes only maintain blocks for the last 5 epochs, if you need historical data you should query instead archival nodes (https://archival-rpc.mainnet.near.org)

See this answer for more details https://stackoverflow.com/a/67199078/4950797