# Method: topicStats.projects.locations.topics.computeMessageStats

- [HTTP request](https://docs.cloud.google.com/pubsub/lite/docs/reference/rest/v1/topicStats.projects.locations.topics/computeMessageStats#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/pubsub/lite/docs/reference/rest/v1/topicStats.projects.locations.topics/computeMessageStats#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/pubsub/lite/docs/reference/rest/v1/topicStats.projects.locations.topics/computeMessageStats#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/pubsub/lite/docs/reference/rest/v1/topicStats.projects.locations.topics/computeMessageStats#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/pubsub/lite/docs/reference/rest/v1/topicStats.projects.locations.topics/computeMessageStats#body.response_body)
  - [JSON representation](https://docs.cloud.google.com/pubsub/lite/docs/reference/rest/v1/topicStats.projects.locations.topics/computeMessageStats#body.ComputeMessageStatsResponse.SCHEMA_REPRESENTATION)
- [Authorization scopes](https://docs.cloud.google.com/pubsub/lite/docs/reference/rest/v1/topicStats.projects.locations.topics/computeMessageStats#body.aspect)

Compute statistics about a range of messages in a given topic and partition.

### HTTP request

`POST https://{endpoint}/v1/topicStats/{topic=projects/*/locations/*/topics/*}:computeMessageStats`

Where `{endpoint}` is one of the [supported service endpoints](https://docs.cloud.google.com/pubsub/lite/docs/reference/rest#rest_endpoints).

The URLs use [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Path parameters

| Parameters ||
|---|---|
| `topic` | `string` Required. The topic for which we should compute message stats. Authorization requires the following [IAM](https://cloud.google.com/iam/docs/) permission on the specified resource `topic`: - `pubsublite.topics.computeMessageStats` |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "partition": string, "startCursor": { object (`https://docs.cloud.google.com/pubsub/lite/docs/reference/rest/v1/Cursor`) }, "endCursor": { object (`https://docs.cloud.google.com/pubsub/lite/docs/reference/rest/v1/Cursor`) } } ``` |

| Fields ||
|---|---|
| `partition` | `string (https://developers.google.com/discovery/v1/type-format format)` Required. The partition for which we should compute message stats. |
| `startCursor` | ``object (`https://docs.cloud.google.com/pubsub/lite/docs/reference/rest/v1/Cursor`)`` The inclusive start of the range. |
| `endCursor` | ``object (`https://docs.cloud.google.com/pubsub/lite/docs/reference/rest/v1/Cursor`)`` The exclusive end of the range. The range is empty if endCursor \<= startCursor. Specifying a startCursor before the first message and an endCursor after the last message will retrieve all messages. |

### Response body

If successful, the response body contains data with the following structure:
Response containing stats for messages in the requested topic and partition.

| JSON representation |
|---|
| ``` { "messageCount": string, "messageBytes": string, "minimumPublishTime": string, "minimumEventTime": string } ``` |

| Fields ||
|---|---|
| `messageCount` | `string (https://developers.google.com/discovery/v1/type-format format)` The count of messages. |
| `messageBytes` | `string (https://developers.google.com/discovery/v1/type-format format)` The number of quota bytes accounted to these messages. |
| `minimumPublishTime` | ``string (`https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp` format)`` The minimum publish timestamp across these messages. Note that publish timestamps within a partition are not guaranteed to be non-decreasing. The timestamp will be unset if there are no messages. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: `"2014-10-02T15:01:23Z"` and `"2014-10-02T15:01:23.045123456Z"`. |
| `minimumEventTime` | ``string (`https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp` format)`` The minimum event timestamp across these messages. For the purposes of this computation, if a message does not have an event time, we use the publish time. The timestamp will be unset if there are no messages. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: `"2014-10-02T15:01:23Z"` and `"2014-10-02T15:01:23.045123456Z"`. |

### Authorization scopes

Requires the following OAuth scope:

- `https://www.googleapis.com/auth/cloud-platform`

For more information, see the [Authentication Overview](https://cloud.google.com/docs/authentication/).