Skip to main content

Access Kaggle resources anywhere

Project description

Kaggle API

Official API for https://www.kaggle.com, accessible using a command line tool implemented in Python 3.

User documentation

Installation

Ensure you have Python 3 and the package manager pip installed.

Run the following command to access the Kaggle API using the command line:

pip install kaggle

Development

Kaggle Internal

Obviously, this depends on Kaggle services. When you're extending the API and modifying or adding to those services, you should be working in your Kaggle mid-tier development environment. You'll run Kaggle locally, in the container, and test the Python code by running it in the container so it can connect to your local testing environment.

Also, run the following command to get autogen.sh installed:

rm -rf /tmp/autogen && mkdir -p /tmp/autogen && unzip -qo /tmp/autogen.zip -d /tmp/autogen &&
mv /tmp/autogen/autogen-*/* /tmp/autogen && rm -rf /tmp/autogen/autogen-* &&
sudo chmod a+rx /tmp/autogen/autogen.sh

Prerequisites

We use hatch to manage this project.

Follow these instructions to install it.

If you are working in a managed environment, you may want to use pipx. If it isn't already installed try sudo apt install pipx. Then you should be able to proceed with pipx install hatch.

Dependencies

hatch run install-deps

Compile

hatch run compile

The compiled files are generated in the kaggle/ directory from the src/ directory.

All the changes must be done in the src/ directory.

Run

You can also run the code in python directly:

hatch run python
import kaggle
from kaggle.api.kaggle_api_extended import KaggleApi
api = KaggleApi()
api.authenticate()
api.model_list_cli()

Next Page Token = [...]
[...]

Or in a single command:

hatch run python -c "import kaggle; from kaggle.api.kaggle_api_extended import KaggleApi; api = KaggleApi(); api.authenticate(); api.model_list_cli()"

Example

Let's change the model_list_cli method in the source file:

 git diff src/kaggle/api/kaggle_api_extended.py
[...]
+        print('hello Kaggle CLI update')^M
         models = self.model_list(sort_by, search, owner, page_size, page_token)
[...] hatch run compile
[...] hatch run python -c "import kaggle; from kaggle.api.kaggle_api_extended import KaggleApi; api = KaggleApi(); api.authenticate(); api.model_list_cli()"
hello Kaggle CLI update
Next Page Token = [...]

Integration Tests

To run integration tests on your local machine, you need to set up your Kaggle API credentials. You can do this in one of these two ways described this doc. Refer to the sections:

  • Using environment variables
  • Using credentials file

After setting up your credentials by any of these methods, you can run the integration tests as follows:

# Run all tests
hatch run integration-test

License

The Kaggle API is released under the Apache 2.0 license.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kaggle-1.7.4.5.tar.gz (336.1 kB view details)

Uploaded Source

Built Distribution

kaggle-1.7.4.5-py3-none-any.whl (181.2 kB view details)

Uploaded Python 3

File details

Details for the file kaggle-1.7.4.5.tar.gz.

File metadata

  • Download URL: kaggle-1.7.4.5.tar.gz
  • Upload date:
  • Size: 336.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.2

File hashes

Hashes for kaggle-1.7.4.5.tar.gz
Algorithm Hash digest
SHA256 1d9821bd6a6a1470741c76d26495a18475b5a7bfe0c80b19191254b2735d41dd
MD5 9955f0d2b75c10a19b4eddd305342062
BLAKE2b-256 b102b0c189a46531ea2b2691ae277508d2c80e5fd3d757083283c5cc27800ca8

See more details on using hashes here.

File details

Details for the file kaggle-1.7.4.5-py3-none-any.whl.

File metadata

  • Download URL: kaggle-1.7.4.5-py3-none-any.whl
  • Upload date:
  • Size: 181.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.2

File hashes

Hashes for kaggle-1.7.4.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9732afb1c073f14acc7e49dfab98456f887d10b735bcd6348bc1340e92393882
MD5 cf09a3d1414bb8dd1752e06e95c17c3d
BLAKE2b-256 14837f29c7abe0d5dc769dad7da993382c3e4239ad63e1dd58414d129e0a4da2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page