Python Metabase API with filter

I need help to understand how to use the python API on a question with a filter. I have a question with a filter, a number, on which I want to have the result on python. I connect to my metabase account, and get the query result with :"/card/300/query"). But when I want to apply the filter “Number”, I am a little lost. I tried to follow this, found on another post :
Parameters should go at the URL , encoded in JSON, in the following format:
[{“type”:“number”, “target”:[“variable”,[“template-tag”,“Number”]],“value”:“400”}]
With payload = {“type”:“number”, “target”:[“variable”,[“template-tag”,“Number”]],“value”:“400”}
&"/card/300/query/json", json = payload)
Does anybody knows how to do it ?

Same issue here.

This is the payload source i'm getting from devtools in Chrome:

I've tried everything to parse that into a POST /api/card/:card-id/query, including the requests parameters "json=", "data=", "params=".
Also tried changing 'Content-Type': 'application/x-www-form-urlencoded' to 'application/json' on the headers request.

Pretty sure there's something about the payload format that must be adjusted before parsing it into a post request, but also, didn't find any clear solution in any topic. Seems like the "parameters" key must be filled with some filtering, but no clear explanation on that, even on github wrappers for Python.
I would also appreciate a hand for a new dev here :slight_smile:

In your devtools result, you have "parameters":[]. This means you are not passing any parameters.
Once you get the correct devtools results, you can use this function from this Python wrapper for Metabase API, to get what you need (pass the value of parameters from devtools to the above function).

Hey @King_Edward, thanks for answering.

Yep, I'm messing around with tables and cards, filtering data, but the parameters key seems to be allways empty:

I will keep trying

Fixed it. Looks like the endpoint I was using was incorrect, @King_Edward.
Even though I was manipulating a card or question on Metabase, the endpoint in the request headers was: 1. Request URL:

So I've just did: response ='', headers=headers, data=json_params),

where the params was:
params = {"database":5,







json_params = json.dumps(params)

@ClementS, pls check the headers of your requests in devtools, maybe the endpoint you should use is also the dataset one..
Thank you all