The majority of monerod RPC calls use the daemon's `json_rpc` interface to request various bits of information. These methods all follow a similar structure, for example:
Block header information can be retrieved using either a block's hash or height. This method includes a block's hash as an input parameter to retrieve basic information about the block.
Inputs:
* *hash* - string; The block's sha256 hash.
Outputs:
* *block_header* - A structure containing block header information. See [getlastblockheader](#getlastblockheader).
In this example, block 912345 is looked up by its hash:
```
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"getblockheaderbyhash","params":{"hash":"e22cf75f39ae720e8b71b3d120a5ac03f0db50bba6379e2850975b4859190bc6"}}' -H 'Content-Type: application/json'
Full block information can be retrieved by either block height or hash, like with the above block header calls. For full block information, both lookups use the same method, but with different input parameters.
Inputs (pick one of the following):
* *height* - unsigned int; The block's height.
* *hash* - string; The block's hash.
Outputs:
* *blob* - string; Hexadecimal blob of block information.
* *block_header* - A structure containing block header information. See [getlastblockheader](#getlastblockheader).
* *prev_id* - Same as `prev_hash` in block header.
* *nonce* - Same as in block header.
* *miner_tx* - Miner transaction information
* *version* - Transaction version number.
* *unlock_time* - The block height when the coinbase transaction becomes spendable.
* *vin* - List of transaction inputs:
* *gen* - Miner txs are coinbase txs, or "gen".
* *height* - This block height, a.k.a. when the coinbase is generated.
* *vout* - List of transaction outputs. Each output contains:
* *amount* - The amount of the output, in atomic units.
* *target* -
* *key* -
* *extra* - Usually called the "transaction ID" but can be used to include any random 32 byte/64 character hex string.
* *signatures* - Contain signatures of tx signers. Coinbased txs do not have signatures.
* *tx_hashes* - List of hashes of non-coinbase transactions in the block. If there are no other transactions, this will be an empty list.
* *status* - string; General RPC error code. "OK" means everything looks good.
**Look up by height:**
In the following example, block 912345 is looked up by its height. Note that block 912345 does not have any non-coinbase transactions. (See the next example for a block with extra transactions):
```
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"getblock","params":{"height":912345}}' -H 'Content-Type: application/json'
* *height* - unsigned int; Current length of longest chain known to daemon.
* *incoming_connections_count* - unsigned int; Number of peers connected to and pulling from your node.
* *outgoing_connections_count* - unsigned int; Number of peers that you are connected to and getting information from.
* *status* - string; General RPC error code. "OK" means everything looks good.
* *target* - unsigned int; Current target for next proof of work.
* *target_height* - unsigned int; The height of the next block in the chain.
* *testnet* - boolean; States if the node is on the testnet (true) or mainnet (false).
* *top_block_hash* - string; Hash of the highest block in the chain.
* *tx_count* - unsigned int; Total number of non-coinbase transaction in the chain.
* *tx_pool_siz* - unsigned int; Number of transactions that have been broadcast but not included in a block.
* *white_peerlist_size* - unsigned int; White Peerlist Size
Following is an example `get_info` call and its return:
```
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_info"}' -H 'Content-Type: application/json'
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"alt_blocks_count": 5,
"difficulty": 972165250,
"grey_peerlist_size": 2280,
"height": 993145,
"incoming_connections_count": 0,
"outgoing_connections_count": 8,
"status": "OK",
"target": 60,
"target_height": 993137,
"testnet": false,
"top_block_hash": "",
"tx_count": 564287,
"tx_pool_size": 45,
"white_peerlist_size": 529
}
}
```
### **hard_fork_info**
Look up information regarding hard fork voting and readiness.
Inputs: *None*.
Outputs:
* *earliest_height* - unsigned int; Block height at which hard fork would be enabled if voted in.
* *enabled* - boolean; Tells if hard fork is enforced.
* *state* - unsigned int; Current hard fork state: 0 (There is likely a hard fork), 1 (An update is needed to fork properly), or 2 (Everything looks good).
* *status* - string; General RPC error code. "OK" means everything looks good.
* *threshold* - unsigned int; Minimum percent of votes to trigger hard fork. Default is 80.
* *version* - unsigned int; The major block version for the fork.
* *votes* - unsigned int; Number of votes towards hard fork.
* *voting* - unsigned int; Hard fork voting status.
* *window* - unsigned int; Number of blocks over which current votes are cast. Default is 10080 blocks.
Example:
```
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"hard_fork_info"}' -H 'Content-Type: application/json'
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"earliest_height": 1009827,
"enabled": false,
"state": 2,
"status": "OK",
"threshold": 0,
"version": 1,
"votes": 7277,
"voting": 2,
"window": 10080
}
}
```
### **setbans**
Ban another node by IP.
Inputs:
* *bans* - A list of nodes to ban:
* *ip* - unsigned int; IP address to ban, in Int format.
* *ban* - boolean; Set `true` to ban.
* *seconds* - unsigned int; Number of seconds to ban node.
Outputs:
* *status* - string; General RPC error code. "OK" means everything looks good.
Example:
```
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"setbans","params":{"bans":[{"ip":838969536,"ban":true,"seconds":30}]}}' -H 'Content-Type: application/json'
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"status": "OK"
}
}
```
### **getbans**
Inputs: *None*.
Outputs:
* *bans* - List of banned nodes:
* *ip* - unsigned int; Banned IP address, in Int format.
* *seconds* - unsigned int; Local Unix time that IP is banned until.
* *status* - string; General RPC error code. "OK" means everything looks good.
Example:
```
$ curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"getbans"}' -H 'Content-Type: application/json'
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"bans": [{
"ip": 838969536,
"seconds": 1457748792
}],
"status": "OK"
}
}
```
---
## Other Daemon RPC Calls
Not all daemon RPC calls use the JSON_RPC interface. This section gives examples of these calls.
The data structure for these calls is different than the JSON RPC calls. Whereas the JSON RPC methods were called using the `/json_rpc` extension and specifying a method, these methods are called at their own extensions. For example:
Note: It is recommended to use JSON RPC where such alternatives exist, rather than the following methods. For example, the recommended way to get a node's height is via the JSON RPC methods [get_info](#getinfo) or [getlastblockheader](#getlastblockheader), rather than [getheight](#getheight) below.
### **/getheight**
Get the node's current height.
Inputs: *None*.
Outputs:
* *height* - unsigned int; Current length of longest chain known to daemon.
```
$ curl -X POST http://127.0.0.1:18081/getheight -H 'Content-Type: application/json'
{
"height": 993488,
"status": "OK"
}
```
### **/gettransactions**
Look up one or more transactions by hash.
Inputs:
* *txs_hashes* - string list; List of transaction hashes to look up.
* *decode_as_json* - boolean; Optional. If set `true`, the returned transaction information will be decoded rather than binary.
Outputs:
* *status* - General RPC error code. "OK" means everything looks good.
* *txs_as_hex* - string; Full transaction information as a hex string.
* *txs_as_json* - json string; (Optional - returned if set in inputs.) List of transaction info:
* *version* - Transaction version
* *unlock_time* - If not 0, this tells when a transaction output is spendable.
* *vin* - List of inputs into transaction:
* *key* - The public key of the previous output spent in this transaction.
* *amount* - The amount of the input, in atomic units.
* *key_offsets* - A list of integer offets to the input.
* *k_image* - The key image for the given input
* *vout* - List of outputs from transaction:
* *amount* - Amount of transaction output, in atomic units.
* *target* - Output destination information:
* *key* - The stealth public key of the receiver. Whoever owns the private key associated with this key controls this transaction output.
* *extra* - Usually called the "payment ID" but can be used to include any random 32 bytes.
Example 1: Return transaction information in binary format.
```
$ curl -X POST http://127.0.0.1:18081/gettransactions -d '{"txs_hashes":["d6e48158472848e6687173a91ae6eebfa3e1d778e65252ee99d7515d63090408"]}' -H 'Content-Type: application/json'
{
"status": "OK",
"txs_as_hex": ["..."]
}
```
Example 2: Decode returned transaction information in JSON format. Note: the "vout" list has been truncated in the displayed return for space considerations.
```
$ curl -X POST http://127.0.0.1:18081/gettransactions -d '{"txs_hashes":["d6e48158472848e6687173a91ae6eebfa3e1d778e65252ee99d7515d63090408"],"decode_as_json":true}' -H 'Content-Type: application/json'
Check if outputs have been spent using the key image associated with the output.
Inputs:
* *key_images* - string list; List of key image hex strings to check.
Outputs:
* *spent_status* - unsigned int list; List of statuses for each image checked. Statuses are follows: 0 = unspent, 1 = spent in blockchain, 2 = spent in transaction pool
* *status* - string; General RPC error code. "OK" means everything looks good.
Example:
```
$ curl -X POST http://127.0.0.1:18081/is_key_image_spent -d '{"key_images":["8d1bd8181bf7d857bdb281e0153d84cd55a3fcaa57c3e570f4a49f935850b5e3","7319134bfc50668251f5b899c66b005805ee255c136f0e1cecbb0f3a912e09d4"]}' -H 'Content-Type: application/json'
{
"spent_status": [1,2],
"status": "OK"
}
```
### **/sendrawtransaction**
Broadcast a raw transaction to the network.
Inputs:
* *tx_as_hex* - string; Full transaction information as hexidecimal string.
Outputs:
* *status* - string; General RPC error code. "OK" means everything looks good. Any other value means that something went wrong.
* *double_spend* - boolean; Transaction is a double spend (`true`) or not (`false`).
* *fee_too_low* - boolean; Fee is too low (`true`) or OK (`false`).
* *invalid_input* - boolean; Input is invalid (`true`) or valid (`false`).
* *invalid_output* - boolean; Output is invalid (`true`) or valid (`false`).
* *low_mixin* - boolean; Mixin count is too low (`true`) or OK (`false`).
* *not_rct* - boolean; Transaction is not a ring transaction (`true`) or a ring transaction (`false`).
* *not_relayed* - boolean; Transaction was not relayed (`true`) or relayed (`false`).
* *overspend* - boolean; Transaction uses more money than available (`true`) or not (`false`).
* *reason* - string; Additional information. Currently empty or "Not relayed" if transaction was accepted but not relayed.
* *too_big* - boolean; Transaction size is too big (`true`) or OK (`false`).
Example (No return information included here.):
```
$ curl -X POST http://127.0.0.1:18081/sendrawtransaction -d '{"tx_as_hex":"de6a3..."}' -H 'Content-Type: application/json'
```
### **/get_transaction_pool**
Show information about valid transactions seen by the node but not yet mined into a block, as well as spent key image information in the node's memory.
Inputs: *None*.
Outputs:
* *spent_key_images* - List of spent output key images: