Registry / data / kaggle

kaggle

JSON →
library2.2.1pypypiunverified

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 kaggle
INSTALL
IMPORT
SIG · KAGGLE
K
kaggle
datapythonv2.2.1
Install
4.2s avg
Import
Disk
37MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.7.4.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 28.6MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 4.2s · import 0.000s · 29MB
37MB installed
● package 37MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

KaggleApi
from kaggle import KaggleApi
from kaggle.api.kaggle_api_extended import KaggleApi

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.

import os from kaggle.api.kaggle_api_extended import KaggleApi # --- Authentication --- # Option 1 (Recommended for local dev): Place kaggle.json in ~/.kaggle/ # (Download from Kaggle profile settings: Account -> 'Create New API Token') # Option 2: Set environment variables (e.g., in your shell or .env file) # export KAGGLE_USERNAME='your_username' # export KAGGLE_KEY='your_api_key' # Initialize the API client api = KaggleApi() api.authenticate() # This will automatically load credentials # --- Example: List competitions --- print('Listing recent competitions:') # Use 'recentlyCreated' for newer competitions, or 'recentlyUpdated' etc. competitions = api.competitions_list(sort_by='recentlyCreated', page_size=5) for comp in competitions: print(f"- {comp.title} (ID: {comp.id})") # --- Example: Download a public dataset --- # Replace 'dataset-owner/dataset-name' with the actual dataset reference. # For example: 'lakshmi25npathi/sentiment-analysis-on-movie-reviews' # Make sure you have permission to download the dataset (some require acceptance of rules). # try: # print(f"\nDownloading dataset...") # api.dataset_download_files( # 'lakshmi25npathi/sentiment-analysis-on-movie-reviews', # path='./data', # unzip=True # ) # print("Dataset downloaded to ./data and unzipped.") # except Exception as e: # print(f"Error downloading dataset: {e}")
kaggle --version
Debug
Known issues
gotchaAuthentication failures are the most common issue. Ensure your Kaggle API credentials (`kaggle.json`) are correctly placed in `~/.kaggle/` or that `KAGGLE_USERNAME` and `KAGGLE_KEY` environment variables are properly set. The library automatically looks for these locations/variables.
fix
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.
affects: All versions
gotchaKaggle enforces dynamic rate limits on API calls. Excessive or rapid requests can lead to HTTP 429 ('Too Many Requests') errors. This is particularly relevant for automated scripts.
fix
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.
affects: All versions
gotchaThe library's behavior, especially regarding authentication and resource caching, can differ when run inside a Kaggle Notebook environment compared to a local machine. For instance, `kagglehub` (a related library) is authenticated by default in Kaggle notebooks, but the `kaggle` CLI requires explicit local setup.
fix
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.
affects: All versions
breakingThe `kaggle` library (Kaggle CLI) now requires Python 3.11 or newer. Older Python versions (e.g., 3.10 and below) are not supported and will lead to installation or runtime errors.
fix
Upgrade your Python environment to version 3.11 or higher. Using a virtual environment is recommended to manage Python versions for different projects.
affects: 2.0.0 and later
Upgrade
Version history
2.2.1latest on PyPI · released Jun 3, 2026
Audit
Dependencies
pythonrequiredRequires Python 3.11 or newer for compatibility.
Agent activity
12 hits · last 30 days
node
10
Resources