Restful
Restful API Reference
Last updated
Restful API Reference
Last updated
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:
The structure of the response message after a request is sent is as follows:
The methods that the client side Restful
interface supports are illustrated below.
GET
http://server:port/api/v1/node/connectioncount
Fetch the current no. of nodes in the network
GET
http://server:port/api/v1/block/transactions/height/{height}
Fetch all transaction hashes for a block at a given height
GET
http://server:port/api/v1/block/details/height/{height}
Fetches block details using block height
GET
http://server:port/api/v1/block/details/hash/{hash}
Fetch block details by block hash
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
GET
http://server:port/api/v1/transaction/{hash}
Fetch transaction details using transaction hash
GET
http://server:port/api/v1/storage/{hash}/{key}
Fetch value using contract address hash and key
GET
http://server:port/api/v1/balance/{addr}
Fetches balance of a Base58 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
GET
http://server:port/api/v1/contract/{hash}
Fetches contract details using contract hash
GET
http://server:port/api/v1/smartcode/event/transactions/{height}
Fetch contract execution result using block height
GET
http://server:port/api/v1/smartcode/event/txhash/{hash}
Fetches contract events using transaction hash
GET
http://server:port/api/v1/block/height/txhash/{hash}
Fetch block height using transaction hash
GET
http://server:port/api/v1/merkleproof/{hash}
Fetch merkle proof using transaction hash
GET
http://localhost:20334/api/v1/gasprice
Fetch gas price
GET
http://server:port/api/v1/allowance/{asset}/{from}/{to}
Fetches amount of allowance of an asset from one account to another
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
GET
http://server:port/api/v1/unboundong/{addr}
Fetch unbound ONG for an account
GET
http://server:port/api/v1/mempool/txcount
Fetch current transaction count in the memory pool
GET
http://server:port/api/v1/mempool/txstate/{hash}
Fetch transaction state in the memory pool
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
GET
http://server:port/api/v1/api/v1/node/syncstatus
Fetch the synchronization status of the node
POST
http://server:port/api/v1/transaction
Send a raw transaction
The error codes in the response message signify the following:
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
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
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 merkle
proof for a transaction using a given transaction hash
Fetch the GAS
price
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 network id
Fetch the grant ONG
Fetch the synchronization status of the node
height
integer
Block height
height
integer
Block height
raw
integer
0 returns raw data, 1 returns serialized data. 0 by default
hash
string
Block hash
raw
integer
0 returns raw data, 1 returns serialized data. 0 by default
height
integer
Block height
hash
string
Transaction hash
raw
integer
0 returns raw data, 1 returns serialized data. 0 by default
hash
string
Contract hash
key
string
Resource key
addr
string
Base58 encoded account address
addr*
String
Base58 encoded account address
hash
string
Contract hash
height
integer
Block height
hash
string
Transaction hash
hash
string
Transaction hash
hash
string
Transaction hash
hash
string
Transaction hash
asset
string
Asset contract hash
from
string
Source account address
to
string
Recipient account address
asset
String
Asset contract hash
from
String
Source account address
to
String
Recipient account address
addr
string
Account address
hash
string
Transaction hash
addr
string
Account address
String
preExec
integer
Set 0 if contract needs to be pre-executed, else 1
Content-Type
string
Set to "application/json"
Action
string
Specifies action, set to "sendrawtransaction"
Version
string
Set to "1.0.0"
Data
string
Data hex code
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