How do I update filters on a Look with the API?

Knowledge Drop

Last tested: Sep 17, 2020
 

  1. Get the existing query using the look endpoint
  2. Create a new query with the updated filter value using the create_query endpoint
  3. Use the query id from the response in step 2 to update the look using update_look

More resources:

Updating Look via API
Update Look with Filters in Python

Example with Python SDK:

### GET QUERY ID FROM LOOK

query = sdk.look(look_id=44).query

##CREATE NEW QUERY AND ADD A FILTER

new_query = sdk.create_query(body=models.WriteQuery(model="dogs_of_new_york", view=query.view, fields=query.fields,

filters={"dog_names_of_nyc.count":100}))

### UPDATE LOOK WITH NEW QUERY ID

sdk.update_look(look_id=44,body=models.WriteLookWithQuery(query_id=new_query.id))

###RUN LOOK

result = sdk.run_look(look_id=44,result_format="csv")

print(result)

This content is subject to limited support.                

Version history
Last update:
‎06-28-2021 11:53 AM
Updated by: