Google Cloud Pub/Sub Topic Stats API

The TopicStats API from Google Cloud Pub/Sub — 3 operation(s) for topicstats.

GitHub OpenAPI

Operations 3

Each operation below carries the questions people ask an LLM about it and the instructions they give an agent to run it. Generated by API Evangelist overlay

POST /v1/topicStats/projects/{projectsId}/locations/{locationsId}/topics/{topicsId}:computeHeadCursor Get the head cursor of a topic partition · Compute head cursor topics #
Ask an LLM
“What is the latest offset in a Pub/Sub Lite topic partition?”
“Is there a cursor that sits at the head of a partition?”
Tell an agent
Get the head cursor for partition {partition} of topic {topic} in {project}/{location}.
Compute the head offset of partition {partition} in {project}/{location}/{topic}.
POST /v1/topicStats/projects/{projectsId}/locations/{locationsId}/topics/{topicsId}:computeTimeCursor Find the cursor for a publish or event time · Compute time cursor topics #
Ask an LLM
“How do I seek a Pub/Sub Lite topic partition to a specific publish time?”
“Can I convert an event time into a cursor?”
Tell an agent
Compute the cursor for time {target} in partition {partition} of {project}/{location}/{topic}.
Seek partition {partition} of {topic} in {project}/{location} to {target}.
POST /v1/topicStats/projects/{projectsId}/locations/{locationsId}/topics/{topicsId}:computeMessageStats Compute message stats for a partition range · Compute message stats topics #
Ask an LLM
“What is the message count and byte size for a range of messages in a partition?”
“Can I get stats for messages between two cursors?”
Tell an agent
Compute message stats for partition {partition} of {topic} in {project}/{location} from {start} to {end}.
Get message count and byte size for partition {partition} of {project}/{location}/{topic} between {start} and {end}.

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/google-cloud-pubsub:google-cloud-pubsub-topicstats-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

google-cloud-pubsub-topicstats-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Pub/Sub Lite Topic Stats API
  version: v1
  description: Generated from Google's published Discovery document for Pub/Sub Lite API (pubsublite v1, revision 20261106). 3 operation(s).
  contact:
    name: Google
    url: https://developers.google.com/
  termsOfService: https://developers.google.com/terms
servers:
- url: https://pubsublite.googleapis.com
tags:
- name: TopicStats
paths:
  /v1/topicStats/projects/{projectsId}/locations/{locationsId}/topics/{topicsId}:computeHeadCursor:
    post:
      operationId: pubsublite.topicStats.projects.locations.topics.computeHeadCursor
      summary: Compute head cursor topics
      description: Compute the head cursor for the partition. The head cursor's offset is guaranteed to be less than or equal to all messages which have not yet been acknowledged as published, and greater than the offset of any message whose publish has already been acknowledged. It is zero if there have never been messages in the partition.
      parameters:
      - name: projectsId
        in: path
        required: true
        description: Resource name segment (projectsId).
        schema:
          type: string
      - name: locationsId
        in: path
        required: true
        description: Resource name segment (locationsId).
        schema:
          type: string
      - name: topicsId
        in: path
        required: true
        description: Resource name segment (topicsId).
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ComputeHeadCursorRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComputeHeadCursorResponse'
        4XX:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GoogleRpcError'
          description: 'Client error (google.rpc.Status: INVALID_ARGUMENT, PERMISSION_DENIED, NOT_FOUND ...)'
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GoogleRpcError'
          description: Error response (google.rpc.Status)
      security:
      - oauth2:
        - https://www.googleapis.com/auth/cloud-platform
      - apiKey: []
      tags:
      - TopicStats
  /v1/topicStats/projects/{projectsId}/locations/{locationsId}/topics/{topicsId}:computeTimeCursor:
    post:
      operationId: pubsublite.topicStats.projects.locations.topics.computeTimeCursor
      summary: Compute time cursor topics
      description: Compute the corresponding cursor for a publish or event time in a topic partition.
      parameters:
      - name: projectsId
        in: path
        required: true
        description: Resource name segment (projectsId).
        schema:
          type: string
      - name: locationsId
        in: path
        required: true
        description: Resource name segment (locationsId).
        schema:
          type: string
      - name: topicsId
        in: path
        required: true
        description: Resource name segment (topicsId).
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ComputeTimeCursorRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComputeTimeCursorResponse'
        4XX:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GoogleRpcError'
          description: 'Client error (google.rpc.Status: INVALID_ARGUMENT, PERMISSION_DENIED, NOT_FOUND ...)'
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GoogleRpcError'
          description: Error response (google.rpc.Status)
      security:
      - oauth2:
        - https://www.googleapis.com/auth/cloud-platform
      - apiKey: []
      tags:
      - TopicStats
  /v1/topicStats/projects/{projectsId}/locations/{locationsId}/topics/{topicsId}:computeMessageStats:
    post:
      operationId: pubsublite.topicStats.projects.locations.topics.computeMessageStats
      summary: Compute message stats topics
      description: Compute statistics about a range of messages in a given topic and partition.
      parameters:
      - name: projectsId
        in: path
        required: true
        description: Resource name segment (projectsId).
        schema:
          type: string
      - name: locationsId
        in: path
        required: true
        description: Resource name segment (locationsId).
        schema:
          type: string
      - name: topicsId
        in: path
        required: true
        description: Resource name segment (topicsId).
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ComputeMessageStatsRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComputeMessageStatsResponse'
        4XX:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GoogleRpcError'
          description: 'Client error (google.rpc.Status: INVALID_ARGUMENT, PERMISSION_DENIED, NOT_FOUND ...)'
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GoogleRpcError'
          description: Error response (google.rpc.Status)
      security:
      - oauth2:
        - https://www.googleapis.com/auth/cloud-platform
      - apiKey: []
      tags:
      - TopicStats
components:
  schemas:
    ComputeHeadCursorRequest:
      description: Compute the current head cursor for a partition.
      type: object
      properties:
        partition:
          format: int64
          type: string
          description: Required. The partition for which we should compute the head cursor.
    TimeTarget:
      description: A target publish or event time. Can be used for seeking to or retrieving the corresponding cursor.
      type: object
      properties:
        publishTime:
          format: google-datetime
          description: Request the cursor of the first message with publish time greater than or equal to `publish_time`. All messages thereafter are guaranteed to have publish times >= `publish_time`.
          type: string
        eventTime:
          description: Request the cursor of the first message with event time greater than or equal to `event_time`. If messages are missing an event time, the publish time is used as a fallback. As event times are user supplied, subsequent messages may have event times less than `event_time` and should be filtered by the client, if necessary.
          format: google-datetime
          type: string
    ComputeTimeCursorResponse:
      description: Response containing the cursor corresponding to a publish or event time in a topic partition.
      type: object
      properties:
        cursor:
          $ref: '#/components/schemas/Cursor'
          description: If present, the cursor references the first message with time greater than or equal to the specified target time. If such a message cannot be found, the cursor will be unset (i.e. `cursor` is not present).
    ComputeMessageStatsResponse:
      properties:
        minimumPublishTime:
          type: string
          description: 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.
          format: google-datetime
        messageCount:
          format: int64
          description: The count of messages.
          type: string
        minimumEventTime:
          description: 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.
          format: google-datetime
          type: string
        messageBytes:
          type: string
          description: The number of quota bytes accounted to these messages.
          format: int64
      type: object
      description: Response containing stats for messages in the requested topic and partition.
    ComputeHeadCursorResponse:
      description: Response containing the head cursor for the requested topic and partition.
      properties:
        headCursor:
          $ref: '#/components/schemas/Cursor'
          description: The head cursor.
      type: object
    ComputeTimeCursorRequest:
      description: Compute the corresponding cursor for a publish or event time in a topic partition.
      properties:
        target:
          $ref: '#/components/schemas/TimeTarget'
          description: Required. The target publish or event time. Specifying a future time will return an unset cursor.
        partition:
          format: int64
          description: Required. The partition for which we should compute the cursor.
          type: string
      type: object
    Cursor:
      type: object
      properties:
        offset:
          description: The offset of a message within a topic partition. Must be greater than or equal 0.
          format: int64
          type: string
      description: A cursor that describes the position of a message within a topic partition.
    GoogleRpcError:
      type: object
      description: The error envelope every Google API returns.
      properties:
        error:
          type: object
          properties:
            code:
              type: integer
            message:
              type: string
            status:
              type: string
            details:
              type: array
              items:
                type: object
    ComputeMessageStatsRequest:
      type: object
      description: Compute statistics about a range of messages in a given topic and partition.
      properties:
        startCursor:
          $ref: '#/components/schemas/Cursor'
          description: The inclusive start of the range.
        partition:
          format: int64
          type: string
          description: Required. The partition for which we should compute message stats.
        endCursor:
          $ref: '#/components/schemas/Cursor'
          description: The exclusive end of the range. The range is empty if end_cursor <= start_cursor. Specifying a start_cursor before the first message and an end_cursor after the last message will retrieve all messages.
  securitySchemes:
    apiKey:
      type: apiKey
      in: query
      name: key
      description: API key; accepted by methods that do not need user data.
    oauth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://accounts.google.com/o/oauth2/auth
          tokenUrl: https://oauth2.googleapis.com/token
          scopes:
            https://www.googleapis.com/auth/cloud-platform: See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
externalDocs:
  url: https://cloud.google.com/pubsub/lite/docs
x-provenance:
  method: harvested
  publisher: Google
  source: https://pubsublite.googleapis.com/$discovery/rest?version=v1
  note: converted by discovery-to-openapi.py from Google's Discovery document (revision 20261106)