By default, Restful API listens on 20334 port.
After a local node has been installed, Restful can be started on the client end using the following command:
The following option can be used to change the port at which the Restful API listens:
ontology --rest --restport 1024
Interface definition
Response parameters
The structure of the response message after a request is sent is as follows:
Response result description
The methods that the client side Restful interface supports are illustrated below.
Fetch the current number of nodes in the network
Fetch all the transaction hashes for a block at a given height
Fetch the block details for a block at a given height
Fetch the block details using the block hash
Fetch the current block height of the blockchain
Fetch the block hash for a block at a given height
Fetch the transaction details using a given transaction hash
Fetch the corresponding value using the contract address hash or the key
Fetch the balance of the account using an address
Fetch the balance of the account using an address, with ONT's decimals being 9, and ONG's decimals being 18
Fetch the contract status using the contract address hash
Fetch the contract execution result for a particular block using the block height
Fetch transaction execution result using a given transaction hash
Fetch the block height at which a transaction was carried out using a given transaction hash
Fetch the merkle proof for a transaction using a given transaction hash
Return the allowance from the from account to the to account
Return the allowance from the from account to the to account, with ONT's decimals being 9, and ONG's decimals being 18
Return the unclaimed ONG for a particular account using a given account address
Fetch the number of transactions stored in the memory
Fetch the transaction status for a given transaction using the transaction hash
Fetch the version information
Send a transaction to the Ontology network
Fetch the synchronization status of the node
GET http://server:port/api/v1/node/connectioncount
Fetch the current no. of nodes in the network
get_blk_txs_by_height
GET http://server:port/api/v1/block/transactions/height/{height}
Fetch all transaction hashes for a block at a given height
Path Parameters
get_blk_by_height
GET http://server:port/api/v1/block/details/height/{height}
Fetches block details using block height
Path Parameters
Query Parameters
0 returns raw data, 1 returns serialized data. 0 by default
get_blk_by_hash
GET http://server:port/api/v1/block/details/hash/{hash}
Fetch block details by block hash
Path Parameters
Query Parameters
0 returns raw data, 1 returns serialized data. 0 by default
GET http://server:port/api/v1/block/height
Fetch the current block height
GET http://server:port/api/v1/block/hash/{height}
Fetch block hash for block at a given height
Path Parameters
GET http://server:port/api/v1/transaction/{hash}
Fetch transaction details using transaction hash
Path Parameters
Query Parameters
0 returns raw data, 1 returns serialized data. 0 by default
GET http://server:port/api/v1/storage/{hash}/{key}
Fetch value using contract address hash and key
Path Parameters
GET http://server:port/api/v1/balance/{addr}
Fetches balance of a Base58 address
Path Parameters
Base58 encoded account address
GET http://server:port/api/v1/balancev2/{addr}
Fetch the balance of the account using an address, with ONT decimals being 9, and ONG decimals being 18
Path Parameters
Base58 encoded account address
get_contract_state
GET http://server:port/api/v1/contract/{hash}
Fetches contract details using contract hash
Path Parameters
get_sc_event_by_height
GET http://server:port/api/v1/smartcode/event/transactions/{height}
Fetch contract execution result using block height
Path Parameters
get_smtcode_evts
GET http://server:port/api/v1/smartcode/event/txhash/{hash}
Fetches contract events using transaction hash
Path Parameters
get_blk_hgt_by_txhash
GET http://server:port/api/v1/block/height/txhash/{hash}
Fetch block height using transaction hash
Path Parameters
get_merkle_proof
GET http://server:port/api/v1/merkleproof/{hash}
Fetch merkle proof using transaction hash
Path Parameters
GET http://localhost:20334/api/v1/gasprice
Fetch gas price
Path Parameters
GET http://server:port/api/v1/allowance/{asset}/{from}/{to}
Fetches amount of allowance of an asset from one account to another
Path Parameters
Recipient account address
get_allowancev2
GET http://server:port/api/v1/allowancev2
Return the allowance from the from account to the to account, with ONT decimals being 9, and ONG decimals being 18
Path Parameters
Recipient account address
GET http://server:port/api/v1/unboundong/{addr}
Fetch unbound ONG for an account
Path Parameters
get_mempooltxcount
GET http://server:port/api/v1/mempool/txcount
Fetch current transaction count in the memory pool
get_mempooltxstate
GET http://server:port/api/v1/mempool/txstate/{hash}
Fetch transaction state in the memory pool
Path Parameters
GET http://server:port/api/v1/version
Fetch node version information
GET http://server:port/api/v1/networkid
Fetches network ID
GET http://server:port/api/v1/grantong/{addr}
Fetch amount of ONG granted to an account
Path Parameters
GET http://server:port/api/v1/api/v1/node/syncstatus
Fetch the synchronization status of the node
Path Parameters
POST http://server:port/api/v1/transaction
Send a raw transaction
Query Parameters
Set 0 if contract needs to be pre-executed, else 1
Set to "application/json"
Specifies action, set to "sendrawtransaction"
The error codes in the response message signify the following:
Session timeout or invalid
Smart contract execution error