query

Execute Query

Execute a step-based query with transformations applied in sequence.

This endpoint uses a pipeline approach where each step transforms the data:

  1. Start with a source table or data model
  2. Apply transformations in order (filter → summarize → order → limit)
  3. Return the final result

Examples:

Simple filtered query:

{
    "source": "orders",
    "steps": [
        {
            "type": "filter",
            "conditions": [
                {"column": "status", "operator": "equals", "value": "completed"},
                {"column": "amount", "operator": "gte", "value": 100}
            ]
        },
        {
            "type": "order_by",
            "columns": [{"column": "created_at", "direction": "desc"}]
        },
        {
            "type": "limit",
            "value": 50
        }
    ]
}

Aggregation query:

{
    "source": "sales",
    "steps": [
        {
            "type": "filter",
            "conditions": [
                {"column": "date", "operator": "gte", "value": "2024-01-01"}
            ]
        },
        {
            "type": "summarize",
            "aggregations": [
                {
                    "column": "revenue",
                    "function": "sum",
                    "label": "total_revenue",
                    "format": "currency:usd"
                },
                {
                    "column": "order_id",
                    "function": "count_distinct",
                    "label": "order_count"
                }
            ],
            "breakdowns": [
                {"column": "region", "label": "Region"},
                {"column": "product_category", "label": "Category"}
            ]
        },
        {
            "type": "order_by",
            "columns": [{"column": "total_revenue", "direction": "desc"}]
        },
        {
            "type": "limit",
            "value": 10
        }
    ]
}

Args: query_request: Step-based query specification query_service: Unified query service (injected via DI) context: Request context (injected via DI)

Returns: QueryResponse with data, metadata

post/query

Request

  • Base URL: https://api.pandas-ai.com (the document declares no server; this is the origin it was published from)
  • URL: https://api.pandas-ai.com/query
  • Auth: none declared

Request body

Response

Successful Response

dataobject[]
columnsstring[]
valuenumber nullable
formatstring nullable
unitstring nullable
querystring required
row_countinteger required
execution_time_msnumber nullable
truncatedboolean

Whether results were truncated due to row limit

explanationobject nullable
errorstring nullable
warningsstring[]

Changes

No recorded changes to this operation across all 1 revision of this API.