Querying a Message with a Specified Time Period
Function
This API is used to query a message with a specified time period.
Calling Method
For details, see Calling APIs.
URI
GET /v2/{project_id}/instances/{instance_id}/management/topics/{topic}/messages
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
project_id |
Yes |
String |
Parameter description: Project ID. For details, see Obtaining a Project ID. Constraints: N/A Value range: N/A Default value: N/A |
|
instance_id |
Yes |
String |
Parameter description: Instance ID. To obtain it, log in to the Kafka console and find the instance ID on the Kafka instance details page. Constraints: N/A Value range: N/A Default value: N/A |
|
topic |
Yes |
String |
Parameter description: Topic name. Constraints: A topic name must start with a letter and can only contain letters, hyphens (-), underscores (_), and digits. Value range: N/A Default value: N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
start_time |
No |
String |
Parameter description: Query start time as a Unix timestamp. Constraints: N/A Value range: N/A Default value: 0 |
|
end_time |
No |
String |
Parameter description: Query end time as a Unix timestamp. Constraints: N/A Value range: N/A Default value: Current system time. |
|
limit |
No |
Integer |
Parameter description: Number of messages returned on a page. Constraints: N/A Value range: N/A Default value: 10 |
|
offset |
No |
Integer |
Parameter description: Offset, which is the position where the query starts. Constraints: N/A Value range: ≥ 0 Default value: N/A |
|
partition |
No |
String |
Parameter description: Partition ID. Constraints: N/A Value range: N/A Default value: The default value is -1, indicating that all partitions are queried. |
Request Parameters
None
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
messages |
Array of messages objects |
Parameter description: Message list. |
|
messages_count |
Integer |
Parameter description: Total number of messages. Value range: N/A |
|
offsets_count |
Integer |
Parameter description: Total number of pages. Value range: N/A |
|
offset |
Integer |
Parameter description: Current page number. Value range: N/A |
|
Parameter |
Type |
Description |
|---|---|---|
|
topic |
String |
Parameter description: Topic name. Value range: N/A |
|
partition |
Integer |
Parameter description: Partition ID. Value range: N/A |
|
message_offset |
Long |
Parameter description: Message ID. Value range: N/A |
|
size |
Integer |
Parameter description: Message size, in bytes. Value range: N/A |
|
timestamp |
Long |
Parameter description: Message production time. The value is a Unix timestamp. The unit is millisecond. Value range: N/A |
Example Requests
GET https://{endpoint}/v2/{project_id}/instances/{instance_id}/management/topics/{topic}/messages
Example Responses
Status code: 200
The message with the specified time period is queried successfully.
{
"messages" : [ {
"topic" : "mytest",
"partition" : 0,
"message_offset" : 7,
"size" : 6,
"timestamp" : 1568125036045
} ],
"messages_count" : 1,
"offsets_count" : 1,
"offset" : 1
}
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
The message with the specified time period is queried successfully. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.