Looker
Run a Looker query
Use an inline query when the application owns the model, view, fields, and filters. Use a saved query ID when the Looker UI or another automation already defined the query.
Documentation reviewed · 2 methods with sources
Ways to do it
- API: POST /api/4.0/queries/run/{result_format}
- API: GET /api/4.0/queries/{query_id}/run/{result_format}
API
POST /api/4.0/queries/run/{result_format}
Run an inline query definition against a Looker model and view.
Read source: Looker run inline query reference- Requirements
- A Looker API client with query permission, a model, view, fields, and any required filters.
- Limitations
- The query must respect the model's access grants and query limits. Result format changes the response representation but not the underlying permissions.
Example json
{"model":"ecommerce","view":"orders","fields":["orders.count"],"filters":{"orders.created_date":"7 days"}}API
GET /api/4.0/queries/{query_id}/run/{result_format}
Run a saved Looker query by its query ID and select the result format.
Read source: Looker run query reference- Requirements
- A Looker API client with permission to run the saved query and a query ID.
- Limitations
- The saved query's model, fields, filters, and access grants control the result. A query ID does not bypass model-level restrictions.
Example shell
curl --fail "https://$LOOKER_HOST/api/4.0/queries/$LOOKER_QUERY_ID/run/json" -H "Authorization: token $LOOKER_ACCESS_TOKEN"