# SQL Explainer API

> SQL Explainer analyzes SQL queries and provides clear, plain English explanations of what they do. Perfect for learning SQL, code reviews, or documentation.

**Endpoint:** `POST https://api.apiverve.com/v1/sqlexplainer`  
**Category:** Data Processing  
**Cost:** 10 credits per call  
**Canonical page:** https://apiverve.com/marketplace/sqlexplainer

## Overview

A SQL explainer API that turns a query into plain English. Send a SELECT, INSERT, UPDATE, DELETE, CREATE or other statement and get back a readable explanation of what it does, the type of operation, and the list of tables it touches. Joins, filters, grouping and ordering are described in terms a non-specialist can follow.

It helps people learning SQL, reviewers reading an unfamiliar query in a pull request, analysts documenting saved reports, and internal tools that show a non-technical user what a query will do before it runs. The tables list is also handy on its own for tagging queries by the data they read or write.

The Free plan returns a short one- or two-sentence explanation, the operation type and the tables. Paid plans let you choose brief, standard, or detailed explanation depth, where detailed adds a step-by-step breakdown, and add a complexity rating of simple, moderate or complex for each query.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl -X POST "https://api.apiverve.com/v1/sqlexplainer" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"SELECT u.name, COUNT(o.id) as order_count FROM users u LEFT JOIN orders o ON u.id = o.user_id WHERE u.created_at > '\''2024-01-01'\'' GROUP BY u.id HAVING COUNT(o.id) > 5 ORDER BY order_count DESC","detail":"standard"}'
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `query` | string | Yes | The SQL query to explain. length 0-50000 |
| `detail` | string | No | Explanation detail level: brief, standard, or detailed. default brief. Premium field |

## Response fields

- `explanation` — string · Plain English explanation of what the SQL query does
- `operation` — string · The type of SQL operation performed by the query
- `tables` — array · List of database tables referenced in the query
- `complexity` — string · The estimated complexity level of the SQL query · (premium)

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "explanation": "This SQL query retrieves the names of users and the number of orders they have placed. It filters users who were created after January 1, 2024. The query then groups the results by user ID and only includes users who have placed more than 5 orders, finally ordering the results by the order count in descending order.",
    "operation": "SELECT",
    "tables": [
      "users",
      "orders"
    ],
    "complexity": "moderate"
  }
}
```

## Use cases

- **Learning SQL** — Understand complex queries while learning database concepts
- **Code Reviews** — Quickly grasp what SQL queries do during reviews
- **Documentation** — Generate explanations for query documentation
- **Debugging** — Understand legacy or unfamiliar queries

## SDKs

- **npm** — `npm install @apiverve/sqlexplainer` (https://www.npmjs.com/package/@apiverve/sqlexplainer)
- **NuGet** — `dotnet add package APIVerve.API.SQLExplainer` (https://www.nuget.org/packages/APIVerve.API.SQLExplainer)
- **Source** — https://github.com/apiverve/sqlexplainer-api

## More

- Full reference: https://docs.apiverve.com/ref/sqlexplainer
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
