# Block

All block commands are below and detailed on related sections.

## Get blocks

> This endpoint lists the blocks created on the PIRI network, based on the skip and limit parameters provided to it.

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Block","description":"All block commands are below and detailed on related sections."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/getBlocks":{"post":{"tags":["Block"],"summary":"Get blocks","description":"This endpoint lists the blocks created on the PIRI network, based on the skip and limit parameters provided to it.","operationId":"getBlocks","requestBody":{"$ref":"#/components/requestBodies/pager"},"responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"$ref":"#/components/schemas/getBlocks"}}}}},"deprecated":false}}},"components":{"requestBodies":{"pager":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"type":"object","properties":{"skip":{"type":"number","default":0,"description":"Page count for skip according to limit value."},"limit":{"type":"number","default":10,"maximum":100,"description":"Record count for per page"}}}}},"required":false}},"schemas":{"getBlocks":{"title":"getBlocks","required":["data","count"],"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/BlockInfo"},"description":"List of blocks"},"count":{"type":"integer","format":"int32","description":"Total count of blocks"}}},"BlockInfo":{"title":"BlockInfo","required":["confirmed","_id","validators","producerAddress","totalFee","blockHeight","previousHash","hash","checkSum","timeStamp","__v","confirmCount"],"type":"object","properties":{"confirmed":{"type":"boolean"},"_id":{"type":"string"},"validators":{"type":"array","items":{"$ref":"#/components/schemas/Validator"}},"producerAddress":{"type":"string"},"totalFee":{"type":"integer","format":"int32"},"blockHeight":{"type":"integer","format":"int32"},"previousHash":{"type":"string"},"hash":{"type":"string"},"checkSum":{"type":"string"},"timeStamp":{"type":"integer","format":"int64"},"__v":{"type":"integer","format":"int32"},"confirmCount":{"type":"integer","format":"int32"}}},"Validator":{"title":"Validator","required":["_id","dateTime","nodeName","nodeAddress","result"],"type":"object","properties":{"_id":{"type":"string"},"dateTime":{"type":"string"},"nodeName":{"type":"string"},"nodeAddress":{"type":"string"},"result":{"type":"integer","format":"int32"}}}}}}
```

## Get blocks with transaction count

> This endpoint lists the blocks created in the PIRI network, similar to the getBlocks endpoint, but the resulting schema also includes the trxCount information for each block.

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Block","description":"All block commands are below and detailed on related sections."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/getBlocksWithTransactionCount":{"post":{"tags":["Block"],"summary":"Get blocks with transaction count","description":"This endpoint lists the blocks created in the PIRI network, similar to the getBlocks endpoint, but the resulting schema also includes the trxCount information for each block.","operationId":"getBlocksWithTransactionCount","requestBody":{"$ref":"#/components/requestBodies/pager"},"responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"$ref":"#/components/schemas/getBlocksWithTransactionCount"}}}}},"deprecated":false}}},"components":{"requestBodies":{"pager":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"type":"object","properties":{"skip":{"type":"number","default":0,"description":"Page count for skip according to limit value."},"limit":{"type":"number","default":10,"maximum":100,"description":"Record count for per page"}}}}},"required":false}},"schemas":{"getBlocksWithTransactionCount":{"title":"getBlocksWithTransactionCount","required":["data","count"],"type":"object","properties":{"data":{"type":"array","description":"Array of blocks with transaction count information","items":{"$ref":"#/components/schemas/BlockWithTransactionCount"}},"count":{"type":"integer","format":"int32","description":"Total number of blocks in the network"}}},"BlockWithTransactionCount":{"title":"BlockWithTransactionCount","required":["confirmed","_id","validators","producerAddress","totalFee","blockHeight","previousHash","hash","checkSum","timeStamp","__v","confirmCount","trxCount"],"type":"object","properties":{"confirmed":{"type":"boolean"},"_id":{"type":"string"},"validators":{"type":"array","items":{"$ref":"#/components/schemas/Validator"},"description":""},"producerAddress":{"type":"string"},"totalFee":{"type":"integer","format":"int32"},"blockHeight":{"type":"integer","format":"int32"},"previousHash":{"type":"string"},"hash":{"type":"string"},"checkSum":{"type":"string"},"timeStamp":{"type":"integer","format":"int64"},"__v":{"type":"integer","format":"int32"},"confirmCount":{"type":"integer","format":"int32"},"trxCount":{"type":"integer","format":"int32"}}},"Validator":{"title":"Validator","required":["_id","dateTime","nodeName","nodeAddress","result"],"type":"object","properties":{"_id":{"type":"string"},"dateTime":{"type":"string"},"nodeName":{"type":"string"},"nodeAddress":{"type":"string"},"result":{"type":"integer","format":"int32"}}}}}}
```

## Get last blocks with block height

> This endpoint uses the limit & blockHeight parameters instead of the skip & limit parameters to list blocks created on the PIRI network. The purpose here is to achieve faster results when page control is provided by the application.

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Block","description":"All block commands are below and detailed on related sections."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/getLastBlocksWithBlockHeight":{"post":{"tags":["Block"],"summary":"Get last blocks with block height","description":"This endpoint uses the limit & blockHeight parameters instead of the skip & limit parameters to list blocks created on the PIRI network. The purpose here is to achieve faster results when page control is provided by the application.","operationId":"getLastBlocksWithBlockHeight","requestBody":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"type":"object","properties":{"limit":{"type":"number","default":10,"maximum":100,"description":"Record count for per page"},"blockHeight":{"type":"number","default":5,"maximum":100,"description":"Block Height (Block Count) to start."}}}}},"required":false},"responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"$ref":"#/components/schemas/getLastBlocksWithBlockHeight"}}}}},"deprecated":false}}},"components":{"schemas":{"getLastBlocksWithBlockHeight":{"title":"getLastBlocksWithBlockHeight","required":["data","count"],"type":"object","properties":{"data":{"type":"array","description":"Array of blocks starting from specified block height","items":{"$ref":"#/components/schemas/SimpleBlockInfo"}},"count":{"type":"integer","format":"int32","description":"Total number of blocks in the network"}}},"SimpleBlockInfo":{"title":"SimpleBlockInfo","required":["confirmed","_id","validators","producerAddress","totalFee","blockHeight","previousHash","hash","checkSum","timeStamp","__v"],"type":"object","properties":{"confirmed":{"type":"boolean"},"_id":{"type":"string"},"validators":{"type":"array"},"producerAddress":{"type":"string"},"totalFee":{"type":"integer","format":"int32"},"blockHeight":{"type":"integer","format":"int32"},"previousHash":{"type":"string"},"hash":{"type":"string"},"checkSum":{"type":"string"},"timeStamp":{"type":"integer","format":"int64"},"__v":{"type":"integer","format":"int32"}}}}}}
```

## Get blocks in descending order

> This endpoint lists the blocks created in the PIRI network in reverse order, based on the skip and limit parameters provided to it. In other words, this endpoint is more convenient for listing newly created blocks.

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Block","description":"All block commands are below and detailed on related sections."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/getBlocksDesc":{"post":{"tags":["Block"],"summary":"Get blocks in descending order","description":"This endpoint lists the blocks created in the PIRI network in reverse order, based on the skip and limit parameters provided to it. In other words, this endpoint is more convenient for listing newly created blocks.","operationId":"getBlocksDesc","requestBody":{"$ref":"#/components/requestBodies/pager"},"responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"$ref":"#/components/schemas/getBlocksDesc"}}}}},"deprecated":false}}},"components":{"requestBodies":{"pager":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"type":"object","properties":{"skip":{"type":"number","default":0,"description":"Page count for skip according to limit value."},"limit":{"type":"number","default":10,"maximum":100,"description":"Record count for per page"}}}}},"required":false}},"schemas":{"getBlocksDesc":{"title":"getBlocksDesc","required":["data","count"],"type":"object","properties":{"data":{"type":"array","description":"Array of blocks in descending order by block height","items":{"$ref":"#/components/schemas/BlockInfo"}},"count":{"type":"integer","format":"int32","description":"Total number of blocks in the network"}}},"BlockInfo":{"title":"BlockInfo","required":["confirmed","_id","validators","producerAddress","totalFee","blockHeight","previousHash","hash","checkSum","timeStamp","__v","confirmCount"],"type":"object","properties":{"confirmed":{"type":"boolean"},"_id":{"type":"string"},"validators":{"type":"array","items":{"$ref":"#/components/schemas/Validator"}},"producerAddress":{"type":"string"},"totalFee":{"type":"integer","format":"int32"},"blockHeight":{"type":"integer","format":"int32"},"previousHash":{"type":"string"},"hash":{"type":"string"},"checkSum":{"type":"string"},"timeStamp":{"type":"integer","format":"int64"},"__v":{"type":"integer","format":"int32"},"confirmCount":{"type":"integer","format":"int32"}}},"Validator":{"title":"Validator","required":["_id","dateTime","nodeName","nodeAddress","result"],"type":"object","properties":{"_id":{"type":"string"},"dateTime":{"type":"string"},"nodeName":{"type":"string"},"nodeAddress":{"type":"string"},"result":{"type":"integer","format":"int32"}}}}}}
```

## Get last blocks

> This endpoint lists the blocks created in the PIRI network based on the limit parameter provided to it. The value given to the limit parameter signifies listing the last x number of blocks.

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Block","description":"All block commands are below and detailed on related sections."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/getLastBlocks":{"post":{"tags":["Block"],"summary":"Get last blocks","description":"This endpoint lists the blocks created in the PIRI network based on the limit parameter provided to it. The value given to the limit parameter signifies listing the last x number of blocks.","operationId":"getLastBlocks","requestBody":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"type":"object","properties":{"limit":{"type":"number","default":10,"minimum":5,"maximum":100,"description":"Record count (descending order)"}}}}},"required":false},"responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"$ref":"#/components/schemas/getLastBlocks"}}}}},"deprecated":false}}},"components":{"schemas":{"getLastBlocks":{"title":"getLastBlocks","required":["data","count"],"type":"object","properties":{"data":{"type":"array","description":"Array of the most recent blocks in the network","items":{"$ref":"#/components/schemas/BlockInfo"}},"count":{"type":"integer","format":"int32","description":"Total number of blocks in the network"}}},"BlockInfo":{"title":"BlockInfo","required":["confirmed","_id","validators","producerAddress","totalFee","blockHeight","previousHash","hash","checkSum","timeStamp","__v","confirmCount"],"type":"object","properties":{"confirmed":{"type":"boolean"},"_id":{"type":"string"},"validators":{"type":"array","items":{"$ref":"#/components/schemas/Validator"}},"producerAddress":{"type":"string"},"totalFee":{"type":"integer","format":"int32"},"blockHeight":{"type":"integer","format":"int32"},"previousHash":{"type":"string"},"hash":{"type":"string"},"checkSum":{"type":"string"},"timeStamp":{"type":"integer","format":"int64"},"__v":{"type":"integer","format":"int32"},"confirmCount":{"type":"integer","format":"int32"}}},"Validator":{"title":"Validator","required":["_id","dateTime","nodeName","nodeAddress","result"],"type":"object","properties":{"_id":{"type":"string"},"dateTime":{"type":"string"},"nodeName":{"type":"string"},"nodeAddress":{"type":"string"},"result":{"type":"integer","format":"int32"}}}}}}
```

## Get only blocks

> This endpoint lists the blocks created on the PIRI network, based on the skip and limit parameters provided. However, the returned result does not include validatorNodes and transaction information. This makes it suitable for quickly browsing the block list.

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Block","description":"All block commands are below and detailed on related sections."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/getOnlyBlocks":{"post":{"tags":["Block"],"summary":"Get only blocks","description":"This endpoint lists the blocks created on the PIRI network, based on the skip and limit parameters provided. However, the returned result does not include validatorNodes and transaction information. This makes it suitable for quickly browsing the block list.","operationId":"getOnlyBlocks","requestBody":{"$ref":"#/components/requestBodies/pager"},"responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"$ref":"#/components/schemas/getOnlyBlocks"}}}}},"deprecated":false}}},"components":{"requestBodies":{"pager":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"type":"object","properties":{"skip":{"type":"number","default":0,"description":"Page count for skip according to limit value."},"limit":{"type":"number","default":10,"maximum":100,"description":"Record count for per page"}}}}},"required":false}},"schemas":{"getOnlyBlocks":{"title":"getOnlyBlocks","required":["data","count"],"type":"object","properties":{"data":{"type":"array","description":"Array of blocks without validator nodes and transaction information for faster browsing","items":{"$ref":"#/components/schemas/BlockInfo"}},"count":{"type":"integer","format":"int32","description":"Total number of blocks in the network"}}},"BlockInfo":{"title":"BlockInfo","required":["confirmed","_id","validators","producerAddress","totalFee","blockHeight","previousHash","hash","checkSum","timeStamp","__v","confirmCount"],"type":"object","properties":{"confirmed":{"type":"boolean"},"_id":{"type":"string"},"validators":{"type":"array","items":{"$ref":"#/components/schemas/Validator"}},"producerAddress":{"type":"string"},"totalFee":{"type":"integer","format":"int32"},"blockHeight":{"type":"integer","format":"int32"},"previousHash":{"type":"string"},"hash":{"type":"string"},"checkSum":{"type":"string"},"timeStamp":{"type":"integer","format":"int64"},"__v":{"type":"integer","format":"int32"},"confirmCount":{"type":"integer","format":"int32"}}},"Validator":{"title":"Validator","required":["_id","dateTime","nodeName","nodeAddress","result"],"type":"object","properties":{"_id":{"type":"string"},"dateTime":{"type":"string"},"nodeName":{"type":"string"},"nodeAddress":{"type":"string"},"result":{"type":"integer","format":"int32"}}}}}}
```

## Get block

> This endpoint returns the most detailed information related to a block created on the PIRI network. The returned object may include validator nodes, transactions, and custom data information.

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Block","description":"All block commands are below and detailed on related sections."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/getBlock":{"post":{"tags":["Block"],"summary":"Get block","description":"This endpoint returns the most detailed information related to a block created on the PIRI network. The returned object may include validator nodes, transactions, and custom data information.","operationId":"getBlock","requestBody":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"required":["blockNumber"],"type":"object","properties":{"blockNumber":{"type":"number","description":"Block Number"}}}}},"required":true},"responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"$ref":"#/components/schemas/getBlock"}}}}},"deprecated":false}}},"components":{"schemas":{"getBlock":{"title":"getBlock","required":["confirmed","_id","validators","producerAddress","totalFee","blockHeight","previousHash","hash","checkSum","timeStamp","__v","confirmCount","lastBlock","trxs"],"type":"object","properties":{"confirmed":{"type":"boolean","description":"Block confirmation status"},"_id":{"type":"string","description":"Block ID"},"validators":{"type":"array","items":{"$ref":"#/components/schemas/Validator"},"description":"List of validator nodes"},"producerAddress":{"type":"string","description":"Block producer address"},"totalFee":{"type":"number","description":"Total transaction fees"},"blockHeight":{"type":"integer","format":"int32","description":"Block height"},"previousHash":{"type":"string","description":"Previous block hash"},"hash":{"type":"string","description":"Block hash"},"checkSum":{"type":"string","description":"Block checksum"},"timeStamp":{"type":"integer","format":"int64","description":"Block timestamp"},"__v":{"type":"integer","format":"int32","description":"Version key"},"confirmCount":{"type":"integer","format":"int32","description":"Confirmation count"},"lastBlock":{"type":"integer","format":"int32","description":"Last block height"},"trxs":{"type":"array","items":{"$ref":"#/components/schemas/Trx"},"description":"List of transactions in block"}}},"Validator":{"title":"Validator","required":["_id","dateTime","nodeName","nodeAddress","result"],"type":"object","properties":{"_id":{"type":"string"},"dateTime":{"type":"string"},"nodeName":{"type":"string"},"nodeAddress":{"type":"string"},"result":{"type":"integer","format":"int32"}}},"Trx":{"title":"Trx","required":["type","confirmed","confirmationCount","_id","transactionHash","__v","amount","assetID","blockHeight","fee","from","pub","signature","symbol","timeStamp","validatorNodes","customDocs"],"type":"object","properties":{"type":{"type":"integer","format":"int32"},"confirmed":{"type":"boolean"},"confirmationCount":{"type":"integer","format":"int32"},"_id":{"type":"string"},"transactionHash":{"type":"string"},"__v":{"type":"integer","format":"int32"},"amount":{"type":"integer","format":"int32"},"assetID":{"type":"integer","format":"int32"},"blockHeight":{"type":"integer","format":"int32"},"fee":{"type":"number"},"from":{"type":"string"},"pub":{"type":"string"},"signature":{"type":"string"},"symbol":{"type":"string"},"timeStamp":{"type":"integer","format":"int64"},"validatorNodes":{"type":"array","items":{"$ref":"#/components/schemas/ValidatorNode"},"description":""},"customDocs":{"type":"array","items":{"$ref":"#/components/schemas/CustomDoc"},"description":""}}},"ValidatorNode":{"title":"ValidatorNode","required":["_id","nodeName","message","dateTime","result"],"type":"object","properties":{"_id":{"type":"string"},"nodeName":{"type":"string"},"message":{"type":"string"},"dateTime":{"type":"string"},"result":{"type":"integer","format":"int32"}}},"CustomDoc":{"title":"CustomDoc","required":["_id","txID","key","value","timeStamp","from","enc","__v","blockHeight"],"type":"object","properties":{"_id":{"type":"string"},"txID":{"type":"string"},"key":{"type":"string"},"value":{"type":"string"},"timeStamp":{"type":"integer","format":"int64"},"from":{"type":"string"},"enc":{"type":"integer","format":"int32"},"__v":{"type":"integer","format":"int32"},"blockHeight":{"type":"integer","format":"int32"}}}}}}
```


---

# 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://api.pirichain.com/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.
