Skip to main content

getBlocks

Retrieves a list of blocks by height range. Blocks with timestamps before the optional timestamp parameter are excluded.

Endpoint

GET /nxt?requestType=getBlocks

Parameters

NameTypeRequiredDefaultDescription
firstIndexintNo0First block index to retrieve (inclusive)
lastIndexintNo100Last block index to retrieve (inclusive)
timestampintNo0Filter: only include blocks with timestamps >= this value
includeTransactionsbooleanNofalseWhether to include full transaction objects instead of just IDs
includeExecutedPhasedbooleanNofalseWhether to include executed phased transaction data

Request Example

curl "http://localhost:22024/nxt?requestType=getBlocks&firstIndex=0&lastIndex=10&includeTransactions=true"

Response

{
"blocks": [
{
"block": "12345678901234567890",
"height": 1000000,
"generator": "1234567890",
"generatorPublicKey": "hexPublicKey",
"timestamp": 123456789,
"numberOfTransactions": 10,
"totalFeeFQT": "100000000",
"version": 1,
"baseTarget": "1234567890",
"cumulativeDifficulty": "123456789012345678901234567890",
"previousBlock": "98765432109876543210",
"payloadHash": "hexPayloadHash",
"generationSignature": "hexGenerationSignature",
"previousBlockHash": "hexPreviousBlockHash",
"blockSignature": "hexBlockSignature",
"transactions": [],
"requestProcessingTime": 5
}
],
"requestProcessingTime": 10
}

Response Fields

FieldTypeDescription
blocksarrayArray of block objects (see Get Block for block fields)
requestProcessingTimenumberAPI request processing time in milliseconds

Source

GetBlocks.java, JSONData.block()

Tags

BLOCKS