How to resolve API query limit 2000 rows?

Hello everyone,

I want to get data for a list 30.000 tracking_id in Python. I tried many ways but it not work as expect.

(My case is 30.000 tracking_id, the code are example for 3 tracking_id)

Way 1: I got limit 2000 rows in JSON result.

payload_1 = '''{"database":6,"native":{"template-tags":{},"query":"SELECT\n    tracking_id\n    ,dest_hub_name\n\nFROM vn_views.transit_time_report\n\nWHERE tracking_id IN ('NLVNMP0018452748VNA', 'NLVNST006802463VN', 'NLVNST006873639VN')"},"type":"native","parameters":[]}'''

res_1 = requests.post(f'https://metabase.mydomain.co/api/dataset, headers={'Content-Type': 'application/json','X-Metabase-Session': cookie}, data=payload_1)

Way 2: I got error response: HTTPError: 400 Client Error: Bad Request for url

payload_2 = '''query=%7B%22database%22%3A6%2C%22native%22%3A%7B%22template-tags%22%3A%7B%7D%2C%22query%22%3A%22SELECT%5Cn++++tracking_id%5Cn++++%2Cdest_hub_name%5Cn%5CnFROM+vn_views.transit_time_report%5Cn%5CnWHERE+tracking_id+IN+%28%27NLVNMP0018452748VNA%27%2C+%27NLVNST006802463VN%27%2C+%27NLVNST006873639VN%27%29%22%7D%2C%22type%22%3A%22native%22%2C%22middleware%22%3A%7B%22js-int-to-string%3F%22%3Atrue%2C%22add-default-userland-constraints%3F%22%3Atrue%7D%7D'''

res_2 = requests.post(f'https://metabase.mydomain.co/api/dataset/json', headers={'Content-Type': 'application/json','X-Metabase-Session': cookie}, data=payload_2)

Way 3: I can not put 30.000 tracking_id to the param because I will get 414 URI Too Long error.

param = '[{"type": "string/=", "target":["dimension", ["template-tag", "tracking_id"]], "value": ["NLVNMP0018452748VNA","NLVNST006802463VN","NLVNST006873639VN"]}]'

res_3 = requests.post(f'https://metabase.mydomain.co/api/card/{question}/query/json?parameters={param}', headers={'Content-Type': 'application/json','X-Metabase-Session': cookie})

Is there anyway for my case? Thank you!

Hi @tranngocminhhieu
Open your browser developer Network-tab, look at the requests or copy as cURL.
I would probably recommend that you use a different tool if you need to use 30k filter options.