Skip to main content

View Query

Gateway prefix: ${API_BASE}/data/views/...

Request body fields (ViewQueryRequest)

  • params object, optional, custom parameters for the view (key-value pairs) used for templated query substitution
  • filters object, optional, Predicate (will be AND-ed with the view’s base_query where clause)
  • limit / offset optional

Parameter placeholders and templating rules

  • View definitions can contain placeholders such as {{country}}, {{channel}}. At execution time they are replaced using params.
  • Missing required parameters will lead to errors (see “Common error examples”).
  • Parameters can be combined with time and other filters to compose the final SQL/DSL.

Execute view query by name

  • POST /views/{viewName}/query

Example (parameters + filters):

curl -X POST \
"${API_BASE}/data/views/sales_overview/query" \
-H "Content-Type: application/json" \
-H "X-Tenant-Id: tenant-abc123" \
-d '{
"params": {"country":"US", "channel":"web"},
"filters": { "type":"comparison", "field":"status", "op":"eq", "value":"PAID" },
"limit": 100
}'

Example response:

{"success": true, "data": {"columns": ["date","revenue"], "rows": [["2024-09-01",1200.5]]}}

Common error examples

  • Missing required view parameter:
{"success": false, "message":"Param 'country' is required", "errorCode":"VIEW_QUERY_FAILED"}
  • View not found:
{"success": false, "message":"View 'sales_overviewx' not found", "errorCode":"VIEW_QUERY_FAILED"}