> ## Documentation Index
> Fetch the complete documentation index at: https://docs.streamkap.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Execute SQL query against Kafka topics

> Parse and execute a SQL query against a Kafka topic.



## OpenAPI

````yaml /openapi/openapi.json post /topics/query
openapi: 3.1.0
info:
  title: Streamkap REST API
  description: >-
    The Streamkap REST API allows you to programmatically manage your CDC
    pipelines, sources, destinations, transforms, and more.


    Authenticate using a bearer token obtained from the [Access
    Token](/api-reference/auth/access-token) endpoint with your API client
    credentials.
  contact:
    name: Streamkap Support
    url: https://streamkap.com/
    email: support@streamkap.com
  license:
    name: Proprietary
  version: 2.0.0
servers:
  - url: https://api.streamkap.com
    description: Production
security: []
tags:
  - name: Agents
    description: Create, deploy, and manage Flink-based AI agents.
  - name: Agents Observability
    description: >-
      Read-only views over the MCP audit log: agent rollup, sessions, spans,
      histograms, external-agent verify.
  - name: Alerts
    description: Manage alert subscribers, preferences, and notification credentials.
  - name: Authentication
    description: Obtain and refresh access tokens, manage client credentials and roles.
  - name: Billing
    description: Retrieve usage metrics, summaries, and export billing data.
  - name: Consumer Groups
    description: List, inspect, and reset Kafka consumer group offsets.
  - name: Dashboard
    description: Retrieve organisation-level statistics and overview data.
  - name: Destinations
    description: Create, configure, and manage data destinations and their lifecycle.
  - name: Kafka Access
    description: Manage Kafka users and their access permissions.
  - name: Logs
    description: Query and summarise system logs.
  - name: Pipelines
    description: Create, configure, and manage CDC pipelines and their lifecycle.
  - name: Project Keys
    description: Manage project keys that bundle API credentials and optional Kafka access.
  - name: Schema Registry
    description: Browse schema subjects, versions, and retrieve schema definitions.
  - name: Services
    description: View and switch service metadata.
  - name: Sources
    description: >-
      Create, configure, and manage data sources, snapshots, and their
      lifecycle.
  - name: Tags
    description: Create, update, and manage resource tags for organisation.
  - name: Topics
    description: Browse topic details, statistics, configurations, metrics, and messages.
  - name: Transforms
    description: >-
      Create, deploy, and manage data transforms, unit tests, and implementation
      details.
paths:
  /topics/query:
    post:
      tags:
        - Topics
      summary: Execute SQL query against Kafka topics
      description: Parse and execute a SQL query against a Kafka topic.
      operationId: executeSqlQuery
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/KafkaSqlQueryReq'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KafkaSqlQueryRes'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - FronteggHTTPAuthentication: []
components:
  schemas:
    KafkaSqlQueryReq:
      properties:
        sql:
          type: string
          maxLength: 10000
          minLength: 1
          title: Sql
          description: SQL query string (e.g., SELECT * FROM topic_name WHERE ... LIMIT 10)
        max_time_seconds:
          type: integer
          maximum: 120
          minimum: 1
          title: Max Time Seconds
          description: Maximum execution time in seconds before the query is terminated
          default: 30
      additionalProperties: true
      type: object
      required:
        - sql
      title: KafkaSqlQueryReq
      description: Request body for executing a SQL query against Kafka topics.
    KafkaSqlQueryRes:
      properties:
        columns:
          items:
            type: string
          type: array
          title: Columns
          description: Column names in the result set
        rows:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Rows
          description: Result rows as dicts
        metadata:
          $ref: '#/components/schemas/KafkaSqlQueryResultMetadata'
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
          description: Error message if the query failed
      additionalProperties: true
      type: object
      title: KafkaSqlQueryRes
      description: Response from executing a SQL query against a Kafka topic.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    KafkaSqlQueryResultMetadata:
      properties:
        records_scanned:
          type: integer
          title: Records Scanned
          default: 0
        records_matched:
          type: integer
          title: Records Matched
          default: 0
        partitions_scanned:
          items:
            type: integer
          type: array
          title: Partitions Scanned
        execution_time_ms:
          type: number
          title: Execution Time Ms
          default: 0
        terminated_by:
          type: string
          title: Terminated By
          description: limit, max_time, max_bytes, or end_of_topic
          default: ''
        bytes_scanned:
          type: integer
          title: Bytes Scanned
          default: 0
        topic:
          type: string
          title: Topic
          description: The topic that was queried
          default: ''
      additionalProperties: true
      type: object
      title: KafkaSqlQueryResultMetadata
      description: Metadata about query execution for the results panel.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    FronteggHTTPAuthentication:
      type: http
      scheme: bearer

````