Kaggle API v2 migration: dataset downloads failing after v1 deprecation
0 reputation · 03 Oct 2022, 17:17 UTC
0 reputation · 03 Oct 2022, 17:17 UTC
With the Kaggle API v1 deprecated, scripts that previously downloaded datasets using v1 personal API keys now need to move to v2. The documented boundary is clear in principle — v1 keys no longer grant access and endpoint URLs plus authentication headers changed — but the exact migration scope for an existing automation is not obvious.
I want to keep an existing dataset-download workflow working under API v2 with minimal changes, while understanding exactly which parts of the old setup are now invalid: the credential format, the download endpoint, or both.
It is unclear whether regenerating credentials produces a v2-compatible key in the same kaggle.json format, or whether the file layout itself changed. I also do not know if the CLI (kaggle datasets download) abstracts the v1/v2 difference entirely, or if direct REST calls in older scripts must be rewritten against new endpoint paths and headers.
33775 reputation · 03 Oct 2022, 20:47 UTC
A newly generated Kaggle API token works with both the current CLI and raw v2 REST endpoints using the same kaggle.json format; no separate credentials are needed.
https://www.kaggle.com/api/v2 when a token is present.https://www.kaggle.com/api/v2 and the authentication header is now Authorization: Kaggle token (replacing the old x-kaggle-key header)./datasets/download/ (owner part optional for public datasets)./competitions//submit but the payload format is different.The v1 deprecation only removed the old base URL and header name; the credential generation process and JSON layout were left unchanged. The CLI was updated to hide the v1/v2 difference, so existing automation that calls kaggle datasets download continues to work after a token refresh.
~/.kaggle/kaggle.json (overwrite the old file).kaggle datasets download <dataset-owner>/<dataset-name>curl -H 'Authorization: Kaggle token <API_KEY>' -o dataset.zip \
https://www.kaggle.com/api/v2/datasets/download/<dataset-owner>/<dataset-name>curl -I https://www.kaggle.com/api/v1/datasets/download/<dataset-owner>/<dataset-name>You should see a 404 or 401 response.To know whether you should expect CLI warnings rather than hard failures, please tell me the exact version of the Kaggle CLI you are currently running (output of kaggle --version).
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.