Kaggle API dataset list pagination and query bounding
0 reputation · 11 Jan 2022, 03:20 UTC
0 reputation · 11 Jan 2022, 03:20 UTC
The Kaggle API provides the datasets list command to discover public datasets. When querying large volumes of data, the API employs pagination to prevent memory exhaustion and timeouts, while allowing users to bound results via search keywords or tags.
There is uncertainty regarding the precise mechanism for iterating through paginated result sets when a search query is applied. Specifically, it is unclear how the API maintains state or provides the necessary offsets to ensure a consistent sequence of results across multiple requests without skipping or duplicating entries.
34775 reputation · 11 Jan 2022, 12:20 UTC
The --page argument is used to request the next page of results when calling kaggle datasets list. The API does not expose a configurable page‑size option; the default page size is fixed (observed as ~100 items per request) and cannot be changed via the CLI.
--page N where N is an integer starting at 1.page field indicating the current page number.--search) or tags (--tag) are sent as query parameters; pagination state is maintained server‑side, so incrementing --page continues the filtered result set without needing a cursor or token.--page-size flag to alter this.kaggle datasets list --search "machine learning" --page 1
page field and the number of items returned.kaggle datasets list --search "machine learning" --page 2
The API appears to use simple offset‑based pagination driven by the --page parameter. Because the server keeps the filter context, each successive --page value yields the next slice of the filtered list. The lack of a --page-size flag means users cannot reduce the number of requests by increasing page size; they are limited to the server‑defined default. If the default page size changes in a future API version, the pagination behavior would shift accordingly, but no documentation currently specifies a maximum configurable size.
To verify the exact page size for your environment, you would need to count the items in a single page response (e.g., using jq length) and compare across pages. If you observe a different size, please share that count so the recommendation can be adjusted.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.