Here we are going to run a look with modified filter values and retrieve the results. This demo uses this Look.
The demo is a simple look which retrieves info for a single given wallet address. This finds the look, extracts the query, updates the parameters and then runs it. Finally results are printed out.
Note this code involves manipulating the query filters. If you want to look at the filters on a given look via the API here is a code snippet to do that:
import jsonimport looker_sdk## CONFIG# This is the address to look upBLACKLISTED_ADDRESS ='0x3b76a3699b563ad1af98ad581714c72315c83607'# This is the look we are going to run.# You can get this from the URL (i.e. https://dashargos.chainargos.com/looks/722 -> 722)LOOK_ID=722# This is the filter we want to set.# While editing the look if you hover over the circled-i next to the relevant dimension# this is given under "NAME"FILTER_TITLE='address'## BEGIN DEMO CODE# initialize connectionsdk = looker_sdk.init40("../looker.ini")# look up this looklook = sdk.look(look_id=str(LOOK_ID))# grab the queryquery = look.query# build the filter we want to use herequery_filter ={ query.view +"."+ FILTER_TITLE: BLACKLISTED_ADDRESS}# construct a new query based on the first onenew_query = sdk.create_query( body=looker_sdk.models40.WriteQuery(model=query.model, view=query.view, fields=query.fields, filters=query_filter))# run itresult_raw = sdk.run_query(query_id=new_query.id, result_format='json_bi')result = json.loads(result_raw)# print resultsassertlen(result['rows'])==1for k, v in result['rows'][0].items():print(str(k) +" : "+str(v))
import jsonimport looker_sdk# This is the look we are going to run.# You can get this from the URL (i.e. https://dashargos.chainargos.com/looks/722 -> 722)LOOK_ID=722# initialize connectionsdk = looker_sdk.init40("../looker.ini")# look up this looklook = sdk.look(look_id=str(LOOK_ID))# and print outprint(look.query.filters)