# Block

## 1. Get latest block list

```javascript
url: /v2/latest-blocks?count=10, 
method: GET, 
params: {
}, 
successResponse: {
    "code":0, 
    "msg":"SUCCESS", 
    "result":[
        {
            "block_hash":"63355f8e80...6c8108e4e56b264d2a", 
            "block_height":112, 
            "txs_root":"472af7d21a83156...75b4c0e0b1b4576531", 
            "bookkeepers":"AMvXn7U9...HyqNr&AL4CDqBikrj...ZAQf2fg1AC", 
            "consensus_data":"12156079575032856115", 
            "block_size":532, 
            "block_time":1522205080, 
            "tx_count":12
        }
    ]
}
```

| Url RequestField | Type | Description                                         |
| ---------------- | ---- | --------------------------------------------------- |
| count            | int  | number of latest blocks. (limited between 1 and 50) |

| ResponseField   | Type   | Description                                     |
| --------------- | ------ | ----------------------------------------------- |
| block\_hash     | String | block hash                                      |
| block\_height   | int    | block height                                    |
| txs\_root       | String | the merkleroot of all transactions in the block |
| bookkeepers     | String | keepers of this block, divided by `&`           |
| consensus\_data | String | consensus data                                  |
| block\_size     | int    | size of this block, unit:bytes                  |
| block\_time     | int    | UNIX time of this block                         |
| tx\_count       | int    | the number of transactions in this block        |

## 2. Get block list by page

```javascript
url：/v2/blocks?page_size=1&page_number=10, 
method：GET, 
successResponse：{
    "code":0, 
    "msg":"SUCCESS", 
    "result":{
        "records":[
            {
                "block_hash":"63355f8e80...6c8108e4e56b264d2a", 
                "block_height":112, 
                "txs_root":"472af7d21a83156...75b4c0e0b1b4576531", 
                "bookkeepers":"AMvXn7U9...HyqNr&AL4CDqBikrj...ZAQf2fg1AC", 
                "consensus_data":"12156079575032856115", 
                "block_size":532, 
                "block_time":1522205080, 
                "tx_count":12
            }
        ], 
        "total":23449
    }
}
```

| Url RequestField | Type | Description                                                               |
| ---------------- | ---- | ------------------------------------------------------------------------- |
| page\_size       | int  | number of records in one page (The page size is limited between 1 and 20) |
| page\_number     | int  | number of the page (At least 1 or greater)                                |

| ResponseField   | Type   | Description                                     |
| --------------- | ------ | ----------------------------------------------- |
| total           | int    | total blocks                                    |
| block\_hash     | String | block hash                                      |
| block\_height   | int    | block height                                    |
| txs\_root       | String | the merkleroot of all transactions in the block |
| bookkeepers     | String | keepers of this block, divided by `&`           |
| consensus\_data | String | consensus data                                  |
| block\_size     | int    | size of this block, unit:bytes                  |
| block\_time     | int    | UNIX time of this block                         |
| tx\_count       | int    | the number of transactions in this block        |

## 3. Get block detail by height or hash

```javascript
url：/v2/blocks/{param}
method：GET
successResponse：
{
	"code":0, 
	"msg":"SUCCESS", 
	"result":{
        "block_hash":"63355f8e80...6c8108e4e56b264d2a", 
        "block_height":112, 
        "txs_root":"472af7d21a83156...75b4c0e0b1b4576531", 
        "bookkeepers":"AL4CDqBikr...Qf2fg1AC&AL...g1AC", 
        "consensus_data":"12156079575032856115", 
        "block_size":532, 
        "block_time":1522205080, 
        "tx_count":12, 
        "txs":[
        	{
        		"tx_hash":"000062c6fe4...9a1c33721", 
        		"tx_type":209, 
        		"tx_time":1522205080, 
        		"confirm_flag":1
        	}
        ]
	}
}
```

| Url Field | Type   | Description                |
| --------- | ------ | -------------------------- |
| param     | String | block height or block hash |

| ResponseField     | Type   | Description                                              |
| ----------------- | ------ | -------------------------------------------------------- |
| block\_hash       | String | block hash                                               |
| block\_height     | int    | block height                                             |
| txs\_root         | String | the merkleroot of all transactions in the block          |
| bookkeepers       | String | keepers of this block, divided by `&`                    |
| consensus\_data   | String | consensus data                                           |
| block\_size       | int    | size of this block, unit:bytes                           |
| block\_time       | int    | UNIX time of this block                                  |
| tx\_count         | int    | the number of transactions in this block                 |
| txs.tx\_hash      | String | transaction hash                                         |
| txs.tx\_type      | int    | transaction type (208/209/210)                           |
| txs.confirm\_flag | int    | transaction state on the blockchain, 1:succees 0:failure |
| txs.tx\_time      | int    | UNIX time of the transaction                             |

## 4. Get latest blocks

```javascript
url：/v2/blocks/generate-time?count=10, 
method：GET, 
successResponse：{
    "code":0, 
    "msg":"SUCCESS", 
    "result":[
		{
			"block_height":1, 
			"generate_time":6
		}, 
		{
			"block_height":2, 
			"generate_time":1
		}
	]
}
```

| RequestField | Type | Description                 |
| ------------ | ---- | --------------------------- |
| count        | int  | number of the latest blocks |

| ResponseField  | Type | Description                           |
| -------------- | ---- | ------------------------------------- |
| block\_height  | int  | block height                          |
| generate\_time | int  | time of block generation，unit:seconds |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ont.io/developer-tools/api/explorer-api/block.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
