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).
* *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_size* - 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.
* *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.
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.
* *do_not_relay* - boolean; Stop relaying transaction to other nodes (default is `false` now; in versions 0.11.1 it was `true`).
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`).
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: