Querying a Message with a Specified Time Period
Function
This API is used to query a message with a specified time period.
Debugging
You can use API Explorer to debug this API.
URI
GET /v2/{project_id}/instances/{instance_id}/management/topics/{topic}/messages
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Project ID. |
| instance_id | Yes | String | Instance ID. |
| topic | Yes | String | Topic name. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| start_time | No | String | Query start time as a Unix timestamp. Default value: 0. |
| end_time | No | String | Query end time, as a Unix timestamp. Default value: current system time. |
| limit | No | Integer | Number of messages returned on a page. Default value: 10. |
| offset | No | Integer | Offset, which is the position where the query starts. The value must be greater than or equal to 0. |
| partition | No | String | Partition number. 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 | Message list. |
| messages_count | Integer | Total number of messages. |
| offsets_count | Integer | Total number of pages. |
| offset | Integer | Current page. |
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.
Last Article: Querying a Message with a Specified Offset
Next Article: Querying Offset of the Earliest Message in a Partition
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.