API Visualizations with Filters

  • 21 June 2018
  • 3 replies

I’ve been trying to run a look using the API, edit the values of existing filters, and return a png graph that I can use. No matter how I try, I can’t seem to run the look with the changes to the filters applied. Is there a specific way this is supposed to be done?

3 replies

Userlevel 3

Hello @Tim_Pansino,

In order to change the filter values on a look via the API, you can

  1. Use the get look endpoint to get the query for a look

  2. Get the query id for that Look

  3. Get the query for that query id

  4. Update the filters on that query

  5. Create a new query in Looker

  6. Update the look with that new query

Here is some example Ruby code written by our very own @brecht that goes through this process:

require 'looker-sdk'


looker =
:client_id => LOOKER_ID,
:client_secret => LOOKER_SECRET,
:api_endpoint => LOOKER_PATH

# get look, here look id 32
my_look = looker.look(32)

# get query id for look
my_query = looker.query(my_look.query_id).to_attrs

# set new filters, here update the value for order_id
my_query[:filters] = {:"order_items.order_id" => "<567"}

# remove the client id!
my_query[:client_id] = {}

# create a new query
my_new_query = looker.create_query(my_query)
puts "New Query ID: " + my_new_query[:id].to_s

# update look with new query
my_look = looker.update_look(32, :query_id => my_new_query[:id])
puts "Updated Look Query ID: " + my_look[:query_id].to_s

if my_new_query[:id] == my_look[:query_id]
puts "Success!"
puts "Fail again, fail better"

Once the look is updated, you can follow the steps in this discourse post to render that Look as an image. If you have any questions about this, let me know!


I’m doing it in python currently.

My issue with creating a new query is that it seems to ruin the visualization options. Not sure why, but it produces errors if you try to run visualizations after updating through the API, even in the web version.

Userlevel 3

Hi @Tim_Pansino, could you please visit and provide some more info? For example, the changes you are making to the query and the visualization options that are affected? Thanks!