import requests
url = "https://app.langwatch.ai/api/v1/query"
payload = { "sql": "<string>" }
headers = {
"X-Auth-Token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Auth-Token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({sql: '<string>'})
};
fetch('https://app.langwatch.ai/api/v1/query', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://app.langwatch.ai/api/v1/query \
--header 'Content-Type: application/json' \
--header 'X-Auth-Token: <api-key>' \
--data '
{
"sql": "<string>"
}
'{
"columns": [
{
"name": "<string>",
"type": "<string>"
}
],
"rows": [
{}
],
"statistics": {
"elapsedMs": 123,
"rowsRead": 123,
"bytesRead": 123,
"rowsReturned": 123
},
"truncated": true,
"followsTimeWindow": true,
"followsGranularity": true,
"diagnostics": [
{
"code": "RESULT_TRUNCATED",
"message": "<string>",
"meta": {}
}
],
"granularitySeconds": 123,
"coarsenedFromSeconds": 123
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}Run a LangWatchQL query
Executes one read-only LangWatchQL SELECT over the analytics datasets and returns typed columns, rows, execution statistics, truncation state and diagnostics. The query runs as a restricted database identity scoped to the authenticated project.
Diagnostics are advisory and never reject a query. An empty diagnostics list means no known issue was detected. It is not proof that the answer is the one you meant.
The project is taken from the credential — no project id appears anywhere in the path or the body, and none can be sent to select another one.
Failures answer with their real HTTP status (a refused query is 403, not 200) and this API’s canonical error envelope — the same code and meta every other REST family publishes.
import requests
url = "https://app.langwatch.ai/api/v1/query"
payload = { "sql": "<string>" }
headers = {
"X-Auth-Token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Auth-Token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({sql: '<string>'})
};
fetch('https://app.langwatch.ai/api/v1/query', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://app.langwatch.ai/api/v1/query \
--header 'Content-Type: application/json' \
--header 'X-Auth-Token: <api-key>' \
--data '
{
"sql": "<string>"
}
'{
"columns": [
{
"name": "<string>",
"type": "<string>"
}
],
"rows": [
{}
],
"statistics": {
"elapsedMs": 123,
"rowsRead": 123,
"bytesRead": 123,
"rowsReturned": 123
},
"truncated": true,
"followsTimeWindow": true,
"followsGranularity": true,
"diagnostics": [
{
"code": "RESULT_TRUNCATED",
"message": "<string>",
"meta": {}
}
],
"granularitySeconds": 123,
"coarsenedFromSeconds": 123
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}Authorizations
Project API key for sending traces and accessing project-scoped resources. Format: sk-lw-... (no underscore). Obtain one by creating a project via the Admin API or the LangWatch UI.
Body
Response
The query ran. Columns, rows, execution statistics, truncation state and diagnostics, scoped to the caller's project.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Was this page helpful?