Generate dashboard chart SQL draft¶
Generate read-only SQL drafts and suggested chart types available for the current data dashboard based on natural language questions. The interface only generates and verifies drafts, does not execute SQL, and does not create Kanban charts.
POST $CLOUDSIGMA_API_BASE/data-dashboards/{dashboard_id}/generate-sql
Before you call¶
Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region. First select the data dashboard that has configured database and data table in Query Data Kanban List.
Prepare personal access token and target workspace ID that can access the target workspace.
Request body¶
Replace $DASHBOARD_ID, $CLOUDSIGMA_API_KEY, $WORKSPACE_ID in the example with actual values.
curl -X POST "$CLOUDSIGMA_API_BASE/data-dashboards/$DASHBOARD_ID/generate-sql" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{
"question": "统计最近 30 天每天的销售额",
"title": "近 30 天销售趋势"
}'
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Data dashboard ID. |
Request body
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
The question you want to answer through data cannot be empty. |
|
string |
No |
Chart title, used to assist in generating drafts. |
Successful response¶
{
"code": "OK",
"msg": "OK",
"data": {
"sql_text": "SELECT sale_date, SUM(amount) AS total_amount FROM sales WHERE sale_date >= DATE_SUB(CURRENT_DATE, INTERVAL 30 DAY) GROUP BY sale_date ORDER BY sale_date",
"chart_type": "line"
}
}
Field |
Type |
Description |
|---|---|---|
|
string |
Generate and verify a read-only SQL draft. |
|
string |
Recommended chart types. Values: |
Error response¶
{
"code": "ErrDataDashboardSQLDraftValidationFailed",
"message": "生成的 SQL 未通过校验"
}
Field |
Type |
Description |
|---|---|---|
|
integer or string |
Error code or status code. |
|
string |
error message. |