Have a requirement to extract SQL that gets executed given a query slug or query id.
I see Looker UI uses /api/internal/dataflux/queries/sql/ to get SQL and display on SQL tab. Is there a way this can be achieved through any APIs
Get SQL queries by query slug or query id
Hey
You can definitely extract the SQL generated using a query ID via Looker’s API. Using the run_query
API endpoint, we can provide the query ID and set the result format to SQL
. For example, the request URL would look like https://<yourdomain>.com:19999/api/3.0/queries/<queryid>/run/sql
.
You could also try this out using the interactive API documentation available on your Looker instance. You can get to the interactive API documentation by navigating to the Admin/API page in Looker and clicking “View API Docs”. On that page, you should see the run_query
endpoint where you can specify a query ID and result format as well.

Reply
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.