Updated on 2023-10-09 GMT+08:00

Listing Blocks

Function

Listing Blocks

URI

GET /v2/agent/apis/channel/{channel_name}/blocks

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

channel_name

Yes

String

Channel name. The value can contain 4 to 24 characters and cannot be the same as the system channel name (testchainid).

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

is_pagination

No

Boolean

Whether to display records on different pages. By default, pagination is not enabled.

Default: false

offset

No

Integer

Offset. The default value is 0.

Minimum: 0

Default: 0

limit

No

Integer

Number of records displayed on each page. The default value is 10. The value ranges from 1 to 50.

Minimum: 1

Maximum: 50

Default: 10

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

count

Integer

Total number of blocks.

data

Array of BlockHeader objects

Block details.

Table 5 BlockHeader

Parameter

Type

Description

block_number

Integer

Block ID.

block_hash

String

Hash of the block.

transaction_count

Integer

Total number of transactions.

data_hash

String

Data hash value.

previous_hash

String

Hash of the previous block.

timestamp

String

Timestamp.

organization_maps

Map<String,Integer>

The key is the creator MSP and the value is the quantity.

Status code: 400

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_message

String

Error description.

error_msg

String

Error description.

Example Requests

  • Default mode request.

    GET  https://192.168.0.90:30603/v2/agent/apis/channel/channel/blocks
  • Paging mode request.

    GET  https://192.168.0.90:30603/v2/agent/apis/channel/channel/blocks?is_pagination=true&offset=1&limit=50

Example Responses

Status code: 200

Success

{
  "count" : 1,
  "data" : [ {
    "block_number" : 0,
    "block_hash" : "Yux2Ea0RNZM95+3R95mvdlI8mH1dvmTSTylPwwzMsbY",
    "transaction_count" : 1,
    "data_hash" : "+3B6RFfbQisE8zt2BeWTvCwP1JbmQLIPeQoiKxoCQVA",
    "previous_hash" : "FlEClYDQJ4cHaEslex9usupte0EqbHyymQ+zUaQcjyE",
    "timestamp" : "2021-01-20T14:38:39+08:00",
    "organization_maps" : "{\"d565e95144ae53b9b3f556de613513f257e720ecMSP\":49}"
  } ]
}

Status code: 400

Bad Request

{
  "error_code" : "BCS.4000013",
  "error_msg" : "request body is too large"
}

Status Codes

Status Code

Description

200

Success

400

Bad Request

Error Codes

See Error Codes.