Skip to content
by Unity Nodes
docs.near.orgapi reference › post query

Post query

Updated 04-11-2026

POST /query This module allows you to make generic requests to the network.

The RpcQueryRequest struct takes in a BlockReference and a QueryRequest.

The BlockReference enum allows you to specify a block by Finality, BlockId or SyncCheckpoint.

The QueryRequest enum provides multiple variants for performing the following actions:

  • View an account's details
  • View a contract's code
  • View the state of an account
  • View the AccessKey of an account
  • View the AccessKeyList of an account
  • Call a function in a contract deployed on the network.

Request body (application/json):

  • id (string): JSON-RPC request id. Auto-populated; can be any string.
  • jsonrpc (string): JSON-RPC protocol version. Always 2.0. one of 2.0
  • method (string, required): one of query
  • params (object, required): one of view_account_by_block_id:
    • block_id (required): one of block_height: integer CryptoHash: string
    • account_id (string, required): NEAR Account Identifier. This is a unique, syntactically valid, human-readable account identifier on the NEAR network. See the crate-level docs for information about validation. Also see Error kind precedence.
    • request_type (string, required): one of view_account view_code_by_block_id:
    • block_id (required): one of block_height: integer CryptoHash: string
    • account_id (string, required)
    • request_type (string, required): one of view_code view_state_by_block_id:
    • block_id (required): one of block_height: integer CryptoHash: string
    • account_id (string, required)
    • after_key_base64: one of StoreKey: string option 2: one of
    • include_proof (boolean)
    • limit (integer, uint32)
    • prefix_base64 (string, bytes, required): This type is used to mark keys (arrays of bytes) that are queried from store. NOTE: Currently, this type is only used in the view_client and RPC to be able to transparently pretty-serialize the bytes arrays as base64-encoded strings (see serialize.rs).
    • request_type (string, required): one of view_state view_access_key_by_block_id:
    • block_id (required): one of block_height: integer CryptoHash: string
    • account_id (string, required)
    • public_key (string, required)
    • request_type (string, required): one of view_access_key view_access_key_list_by_block_id:
    • block_id (required): one of block_height: integer CryptoHash: string
    • account_id (string, required)
    • after_key: one of PublicKeyHandle: string option 2: one of
    • limit (integer, uint32)
    • request_type (string, required): one of view_access_key_list view_gas_key_nonces_by_block_id:
    • block_id (required): one of block_height: integer CryptoHash: string
    • account_id (string, required)
    • public_key (string, required)
    • request_type (string, required): one of view_gas_key_nonces call_function_by_block_id:
    • block_id (required): one of block_height: integer CryptoHash: string
    • account_id (string, required)
    • args_base64 (string, bytes, required): This type is used to mark function arguments. NOTE: The main reason for this to exist (except the type-safety) is that the value is transparently serialized and deserialized as a base64-encoded string when serde is used (serde_json).
    • method_name (string, required)
    • request_type (string, required): one of call_function view_global_contract_code_by_block_id:
    • block_id (required): one of block_height: integer CryptoHash: string
    • code_hash (string, required)
    • request_type (string, required): one of view_global_contract_code view_global_contract_code_by_account_id_by_block_id:
    • block_id (required): one of block_height: integer CryptoHash: string
    • account_id (string, required)
    • request_type (string, required): one of view_global_contract_code_by_account_id view_account_by_finality:
    • finality (string, required): Different types of finality. one of optimistic, near-final, final
    • account_id (string, required)
    • request_type (string, required): one of view_account view_code_by_finality:
    • finality (string, required): one of optimistic, near-final, final
    • account_id (string, required)
    • request_type (string, required): one of view_code view_state_by_finality:
    • finality (string, required): one of optimistic, near-final, final
    • account_id (string, required)
    • after_key_base64: one of StoreKey: string option 2: one of
    • include_proof (boolean)
    • limit (integer, uint32)
    • prefix_base64 (string, bytes, required)
    • request_type (string, required): one of view_state view_access_key_by_finality:
    • finality (string, required): one of optimistic, near-final, final
    • account_id (string, required)
    • public_key (string, required)
    • request_type (string, required): one of view_access_key view_access_key_list_by_finality:
    • finality (string, required): one of optimistic, near-final, final
    • account_id (string, required)
    • after_key: one of PublicKeyHandle: string option 2: one of
    • limit (integer, uint32)
    • request_type (string, required): one of view_access_key_list view_gas_key_nonces_by_finality:
    • finality (string, required): one of optimistic, near-final, final
    • account_id (string, required)
    • public_key (string, required)
    • request_type (string, required): one of view_gas_key_nonces call_function_by_finality:
    • finality (string, required): one of optimistic, near-final, final
    • account_id (string, required)
    • args_base64 (string, bytes, required)
    • method_name (string, required)
    • request_type (string, required): one of call_function view_global_contract_code_by_finality:
    • finality (string, required): one of optimistic, near-final, final
    • code_hash (string, required)
    • request_type (string, required): one of view_global_contract_code view_global_contract_code_by_account_id_by_finality:
    • finality (string, required): one of optimistic, near-final, final
    • account_id (string, required)
    • request_type (string, required): one of view_global_contract_code_by_account_id view_account_by_sync_checkpoint:
    • sync_checkpoint (string, required): one of genesis, earliest_available
    • account_id (string, required)
    • request_type (string, required): one of view_account view_code_by_sync_checkpoint:
    • sync_checkpoint (string, required): one of genesis, earliest_available
    • account_id (string, required)
    • request_type (string, required): one of view_code view_state_by_sync_checkpoint:
    • sync_checkpoint (string, required): one of genesis, earliest_available
    • account_id (string, required)
    • after_key_base64: one of StoreKey: string option 2: one of
    • include_proof (boolean)
    • limit (integer, uint32)
    • prefix_base64 (string, bytes, required)
    • request_type (string, required): one of view_state view_access_key_by_sync_checkpoint:
    • sync_checkpoint (string, required): one of genesis, earliest_available
    • account_id (string, required)
    • public_key (string, required)
    • request_type (string, required): one of view_access_key view_access_key_list_by_sync_checkpoint:
    • sync_checkpoint (string, required): one of genesis, earliest_available
    • account_id (string, required)
    • after_key: one of PublicKeyHandle: string option 2: one of
    • limit (integer, uint32)
    • request_type (string, required): one of view_access_key_list view_gas_key_nonces_by_sync_checkpoint: …