# Kaggle CLI Documentation Welcome to the Kaggle CLI documentation. This guide provides detailed information on how to use the Kaggle command-line interface to interact with Kaggle's platform. ## Installation Note: Ensure you have Python 3.11+. Recommended: install with [pipx](https://pipx.pypa.io/) or [uv](https://docs.astral.sh/uv/), which installs the CLI in an isolated environment and works on all platforms: ```sh pipx install kaggle # or uv tool install kaggle ``` ### Alternative: pip You can also install the package with [pip](https://pypi.org/project/pip/): ```sh pip install kaggle ``` ### Troubleshooting If you see `error: externally-managed-environment`, your operating system protects its system Python (this is the default on recent Debian and Ubuntu releases, among others). Use pipx or uv as described above. If that is not an option, you can override the protection with `--break-system-packages`: ```sh pip install --break-system-packages kaggle ``` Note: this installs the package into the system Python and may conflict with packages managed by your OS. If you run into a `Command kaggle not found` error, ensure that your Python executable scripts are in your $PATH. For a local user install on Linux, the default location is `~/.local/bin`. On Windows, the default location is `$PYTHON_HOME/Scripts`. ## Authentication First, you will need a Kaggle account. You can sign up [here](https://www.kaggle.com/account/login). After login, you can download your Kaggle API credentials at https://www.kaggle.com/settings/api by clicking on the "Generate New Token" button under the "API" section. ### Option 1: OAuth Obtains access credentials for your Kaggle user accounts via a web-based authrorization flow. ```sh kaggle auth login ``` ### Option 2: Environment variable ```sh export KAGGLE_API_TOKEN=xxxxxxxxxxxxxx # Copied from the settings UI ``` ### Option 3: API token file Store your Kaggle API token obtained from your [Kaggle account API tokens settings page](https://www.kaggle.com/settings/api) in a file at `~/.kaggle/access_token`. With Option 2 or 3, the CLI caches the username that belongs to the token in `access_token_cache.json` in the Kaggle config directory (`~/.kaggle`, or `$KAGGLE_CONFIG_DIR` if set), so it doesn't have to look it up on every command. The file holds a hash of the token, never the token itself, and it is safe to delete. ### Option 4: Legacy API credentials file From your [Kaggle account API tokens settings page](https://www.kaggle.com/settings/api), under "Legacy API Credentials", click on the "Create Legacy API Key" button to generate a `kaggle.json` file and store it at `~/.kaggle/kaggle.json`. ## CLI Usage Run the following command to list the available commands: ```sh kaggle --help ``` The Kaggle CLI is organized into several command groups: * [Competitions](./competitions.md): Manage and participate in Kaggle competitions. * [Datasets](./datasets.md): Search, download, and manage Kaggle datasets. * [Forums](./forums.md): Browse and read Kaggle discussion forums. * [Kernels](./kernels.md): Interact with Kaggle Kernels (notebooks and scripts). Includes information on using [Kaggle Secrets](./kernels.md#using-secrets-in-kernels). * [Models](./models.md): Manage your Kaggle Models. * [Model Variations](./model_variations.md): Manage variations of your Kaggle Models. * [Model Variation Versions](./model_variations_versions.md): Manage versions of your Kaggle Model Variations. * [Benchmarks](./benchmarks.md): Define evaluation tasks, run them against LLM models, and download results. * [Configuration](./configuration.md): Configure the Kaggle CLI. Many commands produce output, which can be formatted for different purposes: * [Output Format](./output_format.md): Control the format of output. ## Tutorials Explore these tutorials to learn how to perform common tasks: * [Tutorials](./tutorials.md) * [Create a Dataset](./tutorials.md#tutorial-create-a-dataset) * [Find and Download a Dataset](./tutorials.md#tutorial-find-and-download-a-dataset) * [Create a Model](./tutorials.md#tutorial-create-a-model) * [Create a Model Variation](./tutorials.md#tutorial-create-a-model-variation) * [Create a Model Variation Version](./tutorials.md#tutorial-create-a-model-variation-version) * [How to Submit to a Competition](./tutorials.md#tutorial-how-to-submit-to-a-competition) * [How to Submit to a Code Competition](./tutorials.md#tutorial-how-to-submit-to-a-code-competition)