We are using the python requests module to query Metabase, and trying to figure out how to pass variables to the respective query. The issue is, that while we have been able to successfully pass parameters to Metabase, if the resulting query is greater than 2000 rows, the response from Metabase is limited to 2000 rows.
This issue does not occur when we pass a card number of a pre-written query in Metabase that does not take Metabase variables.
We are trying to figure out why the response from the Metabase API request is limited to 2000 rows when you include parameters in your request. I’ve provided two samples of code below (the 1st calls metabase without variables, and the 2nd calls metabase with variables)
API call without variables: (the response here is NOT limited to 2000 rows)
import requests
url = f'https://metabase.akashi.io/api/card/1332/query/json'
headers = {'Content-Type': 'application/json', 'X-Metabase-Session': '0c451a0e-240e-4afc-b714-4e440cd02213'}
response = requests.post(url, headers=headers)
API call with variables: (this is where the response is limited to 2000 rows)
import requests
url = f'https://metabase.akashi.io/api/card/1541/query'
headers = {'Content-Type': 'application/json', 'X-Metabase-Session': '0c451a0e-240e-4afc-b714-4e440cd02213'}
data = {"parameters": [{"type": "category", "target": ["variable", ["template-tag", "min_id"]], "value": "0"}, {"type": "category", "target": ["variable", ["template-tag", "max_id"]], "value": "3000"}]}
params = {"export-format":"json"}
response = requests.post(url, headers=headers, data=data, params=params)