--- title: Query openapi: POST /api/sql/query sidebarTitle: Query --- ## 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 String that contains the SQL query that needs to be executed. ### Response A list with the column names returned The database where the query is executed The actual data returned by the query in case of the table response type The type of the response table | error | ok ```shell Shell curl --request POST \ --url https://cloud.mindsdb.com/api/sql/query \ --header 'Content-Type: application/json' \ --cookie '{session=273trgsehgrui3i2riurwehe}'\ --data ' { "query": "SELECT * FROM example_db.demo_data.home_rentals LIMIT 10;" } ``` ```python Python import requests url = 'https://cloud.mindsdb.com/api/sql/query' cookies = {'session': '273trgsehgrui3i2riurwehe'} resp = requests.post(url, json={'query': 'SELECT * FROM example_db.demo_data.home_rentals LIMIT 10;'}, cookies=cookies) ``` ```json Response { "column_names": [ "sqft", "rental_price" ], "context": { "db": "mindsdb" }, "data": [ [ 917, 3901 ], [ 194, 2042 ] ], "type": "table" } ```