cURL
curl --request POST \
--url https://api.example.com/query \
--header 'Content-Type: application/json' \
--data '
{
"method": "query",
"params": {
"block_id": 1,
"account_id": "<string>",
"request_type": "view_account"
},
"id": "dontcare",
"jsonrpc": "2.0"
}
'const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
method: 'query',
params: {block_id: 1, account_id: '<string>', request_type: 'view_account'},
id: 'dontcare',
jsonrpc: '2.0'
})
};
fetch('https://api.example.com/query', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.example.com/query"
payload = {
"method": "query",
"params": {
"block_id": 1,
"account_id": "<string>",
"request_type": "view_account"
},
"id": "dontcare",
"jsonrpc": "2.0"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"result": {
"amount": "<string>",
"code_hash": "<string>",
"locked": "<string>",
"storage_usage": 1,
"block_hash": "<string>",
"block_height": 1,
"global_contract_account_id": "<string>",
"global_contract_hash": "<string>",
"storage_paid_at": 0
},
"id": "<string>",
"jsonrpc": "<string>"
}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
AccessKeyof an account - View the
AccessKeyListof an account - Call a function in a contract deployed on the network.
POST
/
query
cURL
curl --request POST \
--url https://api.example.com/query \
--header 'Content-Type: application/json' \
--data '
{
"method": "query",
"params": {
"block_id": 1,
"account_id": "<string>",
"request_type": "view_account"
},
"id": "dontcare",
"jsonrpc": "2.0"
}
'const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
method: 'query',
params: {block_id: 1, account_id: '<string>', request_type: 'view_account'},
id: 'dontcare',
jsonrpc: '2.0'
})
};
fetch('https://api.example.com/query', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.example.com/query"
payload = {
"method": "query",
"params": {
"block_id": 1,
"account_id": "<string>",
"request_type": "view_account"
},
"id": "dontcare",
"jsonrpc": "2.0"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"result": {
"amount": "<string>",
"code_hash": "<string>",
"locked": "<string>",
"storage_usage": 1,
"block_hash": "<string>",
"block_height": 1,
"global_contract_account_id": "<string>",
"global_contract_hash": "<string>",
"storage_paid_at": 0
},
"id": "<string>",
"jsonrpc": "<string>"
}Body
application/json
Available options:
query - view_account_by_block_id
- view_code_by_block_id
- view_state_by_block_id
- view_access_key_by_block_id
- view_access_key_list_by_block_id
- view_gas_key_nonces_by_block_id
- call_function_by_block_id
- view_global_contract_code_by_block_id
- view_global_contract_code_by_account_id_by_block_id
- view_account_by_finality
- view_code_by_finality
- view_state_by_finality
- view_access_key_by_finality
- view_access_key_list_by_finality
- view_gas_key_nonces_by_finality
- call_function_by_finality
- view_global_contract_code_by_finality
- view_global_contract_code_by_account_id_by_finality
- view_account_by_sync_checkpoint
- view_code_by_sync_checkpoint
- view_state_by_sync_checkpoint
- view_access_key_by_sync_checkpoint
- view_access_key_list_by_sync_checkpoint
- view_gas_key_nonces_by_sync_checkpoint
- call_function_by_sync_checkpoint
- view_global_contract_code_by_sync_checkpoint
- view_global_contract_code_by_account_id_by_sync_checkpoint
Show child attributes
Show child attributes
JSON-RPC request id. Auto-populated; can be any string.
JSON-RPC protocol version. Always 2.0.
Available options:
2.0 Was this page helpful?