---
search:
  tags:
    - Topics
    - POST
seo:
  description: >-
    Parse and execute a SQL query against a Kafka topic. Reference for the POST
    /topics/query endpoint in the Streamkap REST API.
sidebar:
  label: Execute SQL query against Kafka topics
  badge: POST
title: Execute SQL query against Kafka topics
type: openapi-operation
---
Parse and execute a SQL query against a Kafka topic.

`POST /topics/query`

**Request body** (`application/json`, required)

- `sql` (string, required) — SQL query string (e.g., SELECT \* FROM topic\_name WHERE ... LIMIT 10)
- `max_time_seconds` (integer) — Maximum execution time in seconds before the query is terminated

Request body example:

```json
{
  "sql": "string",
  "max_time_seconds": 30
}
```

**Responses**

- `200` — Successful Response
- `422` — Validation Error

Response example, 200:

```json
{
  "columns": [
    "string"
  ],
  "rows": [
    {}
  ],
  "metadata": {
    "records_scanned": 0,
    "records_matched": 0,
    "partitions_scanned": [
      0
    ],
    "execution_time_ms": 0,
    "terminated_by": "",
    "bytes_scanned": 0,
    "topic": ""
  },
  "error": "string"
}
```
