Creating a look via the API using a Embedded Explore

  • 13 September 2017
  • 3 replies


We have the looker Explore view Embedded into our application to allow Ad-Hoc analysis of data. Now we would like to expand that functionality so that users can save the explore they create as a look and view it in our product.

The issue is that we can’t use the save Dialog enabled by the “save_content” sso.permission because there is additional information about the look that the user needs to provide before we can display the look as a report in our products UI. So this creates the case where a user could create a look using the explore save and never join it to the rest of the information required to display the report creating a lot of orphaned reports.

The idea we had to solve this is to use the create_look API function to create a new report using the data from the embedded explore view.

This leads to my question, is there a way to access the JSON representing the look created by a Embedded Explore without saving it using the Looker save UI so it can be passed to the API?

Perhaps using javascript embedded events? [Retired] JavaScript Embedded Iframe Events

Thanks in Advanced

3 replies

Userlevel 3


It sounds like you’re intending to call the Looker API from browser javascript. If that’s the case then you should know that the Looker public API currently does not support HTTP requests directly from web browser clients. It’s not possible to configure Looker server support for Access-Control-Allow-Origin for AJAX requests to the Looker public API. (aka CORS )

The recommended practice is for the browser javascript to call api endpoints on an app web server, which contains server-side code that relays the request over to the Looker API. Basically, an API proxy.

If this is in place, then the general plan for creating a look based on an explore would be:

  1. decompose the explore URL to extract the query slug

If the explore URL does not include a “qid=”, and just has model/view info, then that’s what will be needed to construct a query.

If the explore URL involves complex filters, things could get messy because the filters expression syntax in the explore URL may not match the expression syntax for filters in the query filter property of a Look. You would need to do some sort of conversion.

Also note that ideally, the api proxy server would be set up to auth into the Looker API using information provided by the web app as we want to avoid passing Looker user credentials (or access_tokens) back to the browser app for security reasons.

I hope that helps! Feel free to visit if you’re running into specific issues.


That sounds really interesting, and something that we might like to do too.

How did you go with that approach? Did you get it to work?



Hey @David_Ames,

We did get it to work but with some caveats. You can use the current looker API & JavaScript events to generate a look more of less what Rufus describes.

  1. Embed a looker explore with the view SSO permissions set and the CORS set to your URL in both the SSO signature and in the looker admin

  2. Put some JavaScript on the parent page holding the iFrame to listen for the looker change events and constantly keep extracting the query slug from the event response.

  3. As long as you have the most recent query slug you can pass that to your backend processing on form submit or button press in your UI

  4. In your backend processing you how have to pass the query slug to the looker Query API to get the integer query id.

  5. Using this query id you can pass it to the Look API to generate a new look in the embed user’s space.

  6. You can use the returned look ID to embed you custom look where ever you want using the regular SSO embed process.

Now I said there is a caveat… If you create a Look using the above process the filters will not save and there is no way to add them using the current API.

If the create_dashboard API was working you could create a dashboard with the filters attach your look to it then embed the dashboard using the regular SSO embed process but this API is currently disabled in the most recent version of looker and since at least 4.x.

What we ended up doing was directly inserting into the looker database directly to create a dashboard manually and link the filters and look to it. It works perfectly I don’t recommend doing it unless you really have to because its super risky and hopefully the looker team will enabled the create_dashboard endpoint so you don’t have to do it at all.

Good luck,