
Photo by the author
Kaggle CLI (command line interface) enables interaction with kaggle data sets, competitions, notebooks and models directly from the terminal. This is useful for automation of downloading, applications and managing data sets without the need for a web browser. Most of my GitHub work flows employ Kaggle CLI to download or push data sets, because it is the fastest and most effective way.
1. Installation and configuration
Make sure you have a Python 3.10+ installed. Then run the following command in the terminal to install the official API Kaggle:
To obtain Kaggle certificates, download the Kaggle.json file from Kaggle account settings by clicking “Create a new token”.
Then set the environmental variables in the local system:
- Kaggle_username =
- Kaggle_api_key =
2. Competitions
Kaggle competitions are challenges in which you can solve problems with machine learning, download data, send forecasts and see your results on the leader board.
CLI helps to automate everything: browsing competitions, downloading files, sending solutions and more.
List of competitions
kaggle competitions list -s
It shows a list of Kaggle competitions, optionally filtered by the searched date. Useful for discovering novel challenges to join.
Replace competition files
kaggle competitions files
Displays all files available for a specific competition, so you know what data is provided.
Download competition files
kaggle competitions download [-f ] [-p ]
They download the whole or specific files from the competition to the local computer. Exploit -F to determine the file, -p to set the download folder.
Give up
kaggle competitions submit -f -m ""
Send your solution to the competition with optional news describing your application.
List your applications
kaggle competitions submissions
It shows all previous entries for the competition, including the results and time markers.
View the table of leaders
kaggle competitions leaderboard [-s]
Displays the current board of the competition leaders. Exploit -S to show only the highest entries.
3. Data sets
Kaggle data sets are data sets made available by the community. CLI commands from the data set support to find, download and send data sets, as well as manage the data set versions.
Replace data sets
He finds kaggle data sets, optionally filtered by the searched date. Ideal for discovering data for your projects.
List files in the data set
It shows all files contained in a specific set of data, so you can see what is available before downloading.
Download data files
kaggle datasets download / [-f ] [--unzip]
They download the whole or specific files from the data set. Exploit -for automatic zip fawned files.
Initiate data metadata
It creates a metadata file in the folder, preparing it to create a set of data or versions.
Create a novel data set
kaggle datasets create -p
It sends a novel set of data from a folder containing data and metadata.
Create a novel version of the data set
kaggle datasets version -p -m ""
It sends a novel version of the existing data set, with a message describing the changes.
4. Notebooks
Kaggle notebooks are fragments of executable code or notebooks. CLI enables a list, downloading, sending and checking the status of these notebooks, which is useful for sharing or automation of analysis.
List the testicles
Finds public kaggle (testicles) notebooks matching your searched term.
Get the nucleus code
Collects the code of a specific testicle on the local computer.
Initiate nuclear metadata
He creates a metadata file in the folder, preparing it to create or update the testicle.
Update the nucleus
He sends a novel code and launches the nucleus, updating it on Kaggle.
Get the testicle output
kaggle kernels output / -p
They download output files generated by starting the testicle.
Check the status of the testicle
It shows the current status (e.g. startup, complete, unsuccessful) testicles.
5. Models
Kaggle models are the version of machine learning models that you can share, employ or implement again. CLI helps to manage these models, from the list and download to their creation and update.
List models
He finds public models on the kaggle matching the searched term.
Get the model
He downloads the model and its metadata to the local computer.
Initiate model metadata
He creates a metadata file in the folder, preparing it to create a model.
Create a novel model
He sends a novel model to Kaggle from a local folder.
Update the model
It sends a novel version of the existing model.
Remove the model
Removes the model from Kaggle.
6. config
Kaggle Cli configuration commands control default behaviors, such as downloading locations and default competition. Adjust these settings to smoothly flow.
See configuration
Displays the current Kaggle Cli configuration settings (e.g. default competition, download path).
Set the configuration
Set the configuration value, such as the default competition or download path.
Unset config
Removes the configuration value by returning to the default behavior.
7. Tips
- Exploit -H or –Aid after any command to get detailed options and employ
- Exploit -V for CSV output, -q for tranquil mode
- Before downloading or sending to competitions, the rules of the competition on Kaggle should be accepted
Abid Ali Awan (@1abidaliawan) is a certified scientist who loves to build machine learning models. Currently, it focuses on creating content and writing technical blogs on machine learning and data learning technologies. ABID has a master’s degree in technology management and a bachelor’s title in the field of telecommunications engineering. His vision is to build AI with a neural network for students struggling with mental illness.
