The `kaggle` Python library, also known as Kaggle CLI, provides a command-line interface and a Python API to interact with Kaggle resources such as competitions, datasets, models, and notebooks. It enables programmatic listing, downloading, creating, updating, and deleting of these resources. The current version is 2.0.1, with releases happening periodically based on feature additions and bug fixes, ensuring access to the latest Kaggle platform features.
pip install kaggleVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the Kaggle API client and perform a basic operation, such as listing recently created competitions. It also includes commented-out code for downloading a dataset. Ensure you have set up your Kaggle API credentials either by placing `kaggle.json` in `~/.kaggle/` or by setting the `KAGGLE_USERNAME` and `KAGGLE_KEY` environment variables.
Refer to the official Kaggle API documentation for detailed authentication steps. Generate a new API token from your Kaggle account settings and place the `kaggle.json` file in `~/.kaggle/` (on Linux/macOS) or `C:\Users\<Windows-username>\.kaggle\` (on Windows). Alternatively, set `KAGGLE_USERNAME` and `KAGGLE_KEY` as environment variables.
Implement pauses or retry mechanisms with exponential backoff in your code to handle rate limiting. Review your logic to ensure no unintended loops or redundant calls are being made.
Always ensure your local environment is correctly configured for authentication as described above. Be aware that file paths and permissions may also behave differently within Kaggle's sandboxed environments.
Upgrade your Python environment to version 3.11 or higher. Using a virtual environment is recommended to manage Python versions for different projects.