Kaggle/kagglehub

Python library to access Kaggle resources

What it solves

kagglehub simplifies the process of interacting with Kaggle resources—including datasets, models, and competition files—directly from Python. It removes the friction of manually downloading files or managing complex API calls, providing a streamlined way to integrate Kaggle's vast library of AI assets into local or cloud-based workflows.

How it works

The library acts as a Python interface for Kaggle's ecosystem. It handles authentication via API tokens (or automatically within Kaggle notebooks) and manages the downloading and uploading of resources.

Key functionalities include:

  • Resource Management: Users can download specific versions of models and datasets, or target individual files within them.
  • Direct Loading: Through KaggleDatasetAdapter, the library can load Kaggle datasets directly into common data science objects like pandas DataFrames, Polars LazyFrames/DataFrames, or Hugging Face Datasets.
  • Environment Integration: When used inside a Kaggle notebook, resources are automatically attached to the notebook's input panel and served from a shared cache to save disk space. Outside Kaggle, files are stored in a local cache folder.
  • Contribution: It allows users to upload new models and datasets (or new versions of existing ones) directly from their local directories.

Who it’s for

Data scientists, ML engineers, and AI researchers who use Kaggle for sourcing models and datasets or who want to programmatically manage their Kaggle contributions.

Highlights

  • Multi-framework Data Loading: Native support for loading data into pandas, Polars, and Hugging Face formats.
  • Flexible Downloads: Ability to download entire resources, specific versions, or single files.
  • Seamless Notebook Integration: Optimized behavior for Kaggle's own notebook environment.
  • Comprehensive Uploads: Simple functions to upload models and datasets with version notes and file ignore patterns.

Related

  • Project
  • Dispatch
  • Project
  • Project
  • Project