Metabase API request for query with parameters is constrained to 2000 rows (using python requests module)

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)

Hi @wbmcdonald4
Metabase has a “view” limit of 2,000 rows of unaggregated data (or 10,000 rows of aggregated data)
There’s a limit of 1 million rows, when downloading data.
The difference between your two API calls is the URL. The first is downloading (as JSON - or CSV or XLSX), second is “viewing”.
If you change the second call URL to https://metabase.akashi.io/api/card/1541/query/json , then the limit is 1 million rows.

1 Like