Updated on 2023-08-29 GMT+08:00

Querying the Partition List of a Topic

Function

This API is used to query the partition list of a topic.

URI

GET /v2/{project_id}/kafka/instances/{instance_id}/topics/{topic}/partitions

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID.

Minimum: 1

Maximum: 64

instance_id

Yes

String

Instance ID.

Minimum: 1

Maximum: 64

topic

Yes

String

Topic.

Minimum: 1

Maximum: 200

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

offset

No

Integer

Offset. The records after this offset will be queried.

Minimum: 0

Maximum: 10000

limit

No

Integer

Maximum number of records that can be returned.

Minimum: 1

Maximum: 50

Request Parameters

None

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

total

Integer

Total records.

Minimum: 0

Maximum: 100

partitions

Array of partitions objects

Partition array.

Table 4 partitions

Parameter

Type

Description

partition

Integer

Partition ID.

Minimum: 0

Maximum: 100

start_offset

Long

Start offset.

Minimum: 0

Maximum: 9223372036854775807

last_offset

Long

Last offset.

Minimum: 0

Maximum: 9223372036854775807

message_count

Long

Number of messages in a partition.

Minimum: 0

Maximum: 9223372036854775807

last_update_time

Long

Last update time.

Minimum: 0

Maximum: 9223372036854775807

Example Requests

Querying the partition list of a topic

GET https://{endpoint}/v2/{project_id}/kafka/instances/{instance_id}/topics/{topic}/partitions?start=1&limit=10

Example Responses

Status code: 200

The partition list of the topic is queried successfully.

{
  "total" : 3,
  "partitions" : [ {
    "partition" : 0,
    "start_offset" : 0,
    "last_offset" : 1216303,
    "message_count" : 1216303,
    "last_update_time" : 1688011291458
  }, {
    "partition" : 1,
    "start_offset" : 0,
    "last_offset" : 985447,
    "message_count" : 985447,
    "last_update_time" : 1688011291469
  }, {
    "partition" : 2,
    "start_offset" : 0,
    "last_offset" : 923340,
    "message_count" : 923340,
    "last_update_time" : 1688011291526
  } ]
}

Status Codes

Status Code

Description

200

The partition list of the topic is queried successfully.

Error Codes

See Error Codes.