Restful
Restful API Reference
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:
Interface definition
Response parameters
The structure of the response message after a request is sent is as follows:
Field | Data type | Description |
Action | String | Response action name |
Desc | String | Response result description |
Error | Integer | Error code |
Result | Object | Execution result |
Version | String | Version number |
Method list
The methods that the client side Restful
interface supports are illustrated below.
Method | Description |
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 | |
Fetch the | |
Return the allowance from the | |
Return the allowance from the | |
Return the unclaimed | |
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 network id | |
Fetch the | |
Fetch the synchronization status of the node |
get_conn_count
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
Name | Type | Description |
---|---|---|
height | integer | Block height |
get_blk_by_height
GET
http://server:port/api/v1/block/details/height/{height}
Fetches block details using block height
Path Parameters
Name | Type | Description |
---|---|---|
height | integer | Block height |
Query Parameters
Name | Type | Description |
---|---|---|
raw | integer | 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
Name | Type | Description |
---|---|---|
hash | string | Block hash |
Query Parameters
Name | Type | Description |
---|---|---|
raw | integer | 0 returns raw data, 1 returns serialized data. 0 by default |
get_blk_height
GET
http://server:port/api/v1/block/height
Fetch the current block height
get_blk_hash
GET
http://server:port/api/v1/block/hash/{height}
Fetch block hash for block at a given height
Path Parameters
Name | Type | Description |
---|---|---|
height | integer | Block height |
get_tx
GET
http://server:port/api/v1/transaction/{hash}
Fetch transaction details using transaction hash
Path Parameters
Name | Type | Description |
---|---|---|
hash | string | Transaction hash |
Query Parameters
Name | Type | Description |
---|---|---|
raw | integer | 0 returns raw data, 1 returns serialized data. 0 by default |
get_storage
GET
http://server:port/api/v1/storage/{hash}/{key}
Fetch value using contract address hash and key
Path Parameters
Name | Type | Description |
---|---|---|
hash | string | Contract hash |
key | string | Resource key |
get_balance
GET
http://server:port/api/v1/balance/{addr}
Fetches balance of a Base58 address
Path Parameters
Name | Type | Description |
---|---|---|
addr | string | Base58 encoded account address |
get_balancev2
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
Name | Type | Description |
---|---|---|
addr* | String | Base58 encoded account address |
get_contract_state
GET
http://server:port/api/v1/contract/{hash}
Fetches contract details using contract hash
Path Parameters
Name | Type | Description |
---|---|---|
hash | string | Contract hash |
get_sc_event_by_height
GET
http://server:port/api/v1/smartcode/event/transactions/{height}
Fetch contract execution result using block height
Path Parameters
Name | Type | Description |
---|---|---|
height | integer | Block height |
get_smtcode_evts
GET
http://server:port/api/v1/smartcode/event/txhash/{hash}
Fetches contract events using transaction hash
Path Parameters
Name | Type | Description |
---|---|---|
hash | string | Transaction hash |
get_blk_hgt_by_txhash
GET
http://server:port/api/v1/block/height/txhash/{hash}
Fetch block height using transaction hash
Path Parameters
Name | Type | Description |
---|---|---|
hash | string | Transaction hash |
get_merkle_proof
GET
http://server:port/api/v1/merkleproof/{hash}
Fetch merkle proof using transaction hash
Path Parameters
Name | Type | Description |
---|---|---|
hash | string | Transaction hash |
get_gasprice
GET
http://localhost:20334/api/v1/gasprice
Fetch gas price
Path Parameters
Name | Type | Description |
---|---|---|
hash | string | Transaction hash |
get_allowance
GET
http://server:port/api/v1/allowance/{asset}/{from}/{to}
Fetches amount of allowance of an asset from one account to another
Path Parameters
Name | Type | Description |
---|---|---|
asset | string | Asset contract hash |
from | string | Source account address |
to | string | 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
Name | Type | Description |
---|---|---|
asset | String | Asset contract hash |
from | String | Source account address |
to | String | Recipient account address |
get_unboundong
GET
http://server:port/api/v1/unboundong/{addr}
Fetch unbound ONG for an account
Path Parameters
Name | Type | Description |
---|---|---|
addr | string | Account address |
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
Name | Type | Description |
---|---|---|
hash | string | Transaction hash |
get_version
GET
http://server:port/api/v1/version
Fetch node version information
get_networkid
GET
http://server:port/api/v1/networkid
Fetches network ID
get_grantong
GET
http://server:port/api/v1/grantong/{addr}
Fetch amount of ONG granted to an account
Path Parameters
Name | Type | Description |
---|---|---|
addr | string | Account address |
get_syncstatus
GET
http://server:port/api/v1/api/v1/node/syncstatus
Fetch the synchronization status of the node
Path Parameters
Name | Type | Description |
---|---|---|
String |
post_raw_tx
POST
http://server:port/api/v1/transaction
Send a raw transaction
Query Parameters
Name | Type | Description |
---|---|---|
preExec | integer | Set 0 if contract needs to be pre-executed, else 1 |
Headers
Name | Type | Description |
---|---|---|
Content-Type | string | Set to "application/json" |
Request Body
Name | Type | Description |
---|---|---|
Action | string | Specifies action, set to "sendrawtransaction" |
Version | string | Set to "1.0.0" |
Data | string | Data hex code |
Error codes
The error codes in the response message signify the following:
Field | Data type | Description |
0 | int64 | Success |
41001 | int64 | Session timeout or invalid |
41002 | int64 | Service limit reached |
41003 | int64 | Invalid data format |
41004 | int64 | Invalid version number |
42001 | int64 | Invalid function |
42002 | int64 | Invalid parameter |
43001 | int64 | Invalid transaction |
43002 | int64 | Invalid resource |
43003 | int64 | Invalid block |
44001 | int64 | Unknown transaction |
44002 | int64 | Unknown resource |
44003 | int64 | Unknown block |
45001 | int64 | Internal error |
47001 | int64 | Smart contract execution error |
Last updated