Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mindsdb-dependabot-npm-and-yarn-docs-multi-e24c86a36e.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Description

This API provides a REST endpoint for executing the SQL queries. Note:
  • This endpoint is a HTTP POST method.
  • This endpoint accept data via application/json request body.
  • The only required key is the query which has the SQL statement value.

Body

query
string
required
String that contains the SQL query that needs to be executed.
response_format
string
Format of the response. Available options:
  • null (default) - returns all data in a single JSON response
  • "sse" - returns data as Server-Sent Events stream
  • "jsonlines" - returns data as JSON Lines stream (one JSON object per line)
Use "sse" or "jsonlines" for streaming large result sets to avoid loading all data into memory at once.
context
object
Optional context object, e.g., {"db": "mindsdb"} to specify the database.
params
object
Optional parameters for parameterized queries, e.g., {"name": "value"}.

Response

column_names
array
required
A list with the column names returned
context
object
required
The database where the query is executed
data
array
The actual data returned by the query in case of the table response type
type
string
The type of the response table | error | ok
curl --request POST \
     --url https://cloud.mindsdb.com/api/sql/query \
     --header 'Content-Type: application/json' \
     --data '
{
     "query": "SELECT * FROM example_db.demo_data.home_rentals LIMIT 10;"
}
'
{
    "column_names": [
        "sqft",
        "rental_price"
    ],
    "context": {
        "db": "mindsdb"
    },
    "data": [
        [
            917,
            3901
        ],
        [
            194,
            2042
        ]
    ],
    "type": "table"
}