Registry / http-networking / kagglesdk

kagglesdk

JSON →
library0.1.37pypypi✓ verified 23d ago

The `kagglesdk` is the official Python client library for interacting with Kaggle's external-facing APIs, allowing users to programmatically access competitions, datasets, kernels, and more. It is currently at version 0.1.18 and receives frequent updates.

pip install kagglesdk
INSTALL
IMPORT
SIG · KAGGLESDK
K
kagglesdk
http-networkingpythonv0.1.37
Install
2.7s avg
Import
833ms
Disk
25MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.28 · 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.95 runs
installs and imports cleanly · install 0.0s · import 0.966s · 26.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.7s · import 0.700s · 27MB
25MB installed
● package 25MB
Code
Verified usage

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

KaggleClient
from kagglesdk import KaggleClient
import kaggle

This quickstart demonstrates how to authenticate with the Kaggle API client and then use it to list active competitions. It also includes a commented-out example for downloading a dataset. Ensure your Kaggle API credentials (`kaggle.json` file or `KAGGLE_USERNAME`, `KAGGLE_KEY` environment variables) are correctly configured before running.

import os import kaggle # --- Kaggle API Authentication --- # The client expects credentials in one of two ways: # 1. A `kaggle.json` file in `~/.kaggle/` (recommended for local development) # 2. Environment variables: `KAGGLE_USERNAME` and `KAGGLE_KEY` # For example, in your shell: # export KAGGLE_USERNAME="your_username" # export KAGGLE_KEY="your_api_key" # Initialize and authenticate the API client # This call implicitly uses the `kaggle.json` file or environment variables. kaggle.api.authenticate() print("Successfully authenticated to Kaggle API.") # --- Example Usage: List active competitions --- print("\nActive Competitions:") try: # competition_list returns a generator-like object competitions = kaggle.api.competition_list(category='active', sort_by='recentlyStarted') for competition in competitions: print(f"- {competition.ref}: {competition.title}") except Exception as e: print(f"Error listing competitions: {e}") # --- Example Usage: Download a dataset (uncomment to run) --- # dataset_name = 'titanic' # download_path = './data' # os.makedirs(download_path, exist_ok=True) # print(f"\nDownloading dataset '{dataset_name}' to '{download_path}'...") # try: # kaggle.api.dataset_download_files(dataset_name, path=download_path, unzip=True) # print(f"Dataset '{dataset_name}' downloaded and unzipped successfully.") # except Exception as e: # print(f"Error downloading dataset '{dataset_name}': {e}")
Debug
Known issues
gotchaThe PyPI package name is `kagglesdk`, but it is imported as the `kaggle` module (e.g., `import kaggle`). Attempting to import directly from `kagglesdk` (e.g., `from kagglesdk import api`) will result in an `ImportError` or unexpected behavior.
fix
Always use `import kaggle` to access the client functionality, then interact via `kaggle.api`.
affects: All versions
gotchaAuthentication is typically managed by `kaggle.api.authenticate()`, which looks for a `kaggle.json` file in `~/.kaggle/` or the `KAGGLE_USERNAME` and `KAGGLE_KEY` environment variables. If credentials are not found, an `ApiException` will be raised.
fix
Generate your Kaggle API token from your Kaggle account settings and place `kaggle.json` in `~/.kaggle/`, or set the corresponding environment variables.
affects: All versions
gotchaWhen downloading files (e.g., `dataset_download_files`, `competition_download_files`), the `path` argument specifies the destination directory. If a relative path is provided, it's relative to the current working directory. Files are often downloaded as ZIP archives, and `unzip=True` is commonly used.
fix
Always provide an absolute path for `path` using `os.path.abspath()` or `os.path.join(os.getcwd(), 'your_dir')` for predictable file locations, and set `unzip=True` if you expect archive files.
affects: All versions
gotchaThe Kaggle API client does not automatically handle rate limiting. Frequent or rapid requests, especially in loops or automated scripts, can lead to your IP being temporarily blocked by Kaggle's servers.
fix
Implement delays (e.g., `time.sleep()`) between successive API calls, particularly when performing bulk operations, to avoid hitting rate limits.
affects: All versions
gotchaAPI methods typically return custom objects (e.g., `Competition`, `Dataset`) or lists of these objects, not raw Python dictionaries. Access data using dot notation (e.g., `competition.ref`, `competition.title`).
fix
Familiarize yourself with the object structure by consulting the Kaggle API documentation or by inspecting objects using `dir()` or `type()`.
affects: All versions
Upgrade
Version history
0.1.37latest on PyPI · released Aug 6, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
12
Resources
kagglesdk — pip install kagglesdk · libregistry