Category: api
Question: How can you interact with Datasets using Kaggle's CLI an API?
Answer: The Kaggle API and CLI tool provide easy ways to interact with Datasets on Kaggle. The commands available can make searching for and downloading Kaggle Datasets a seamless part of your data science workflow.

If you haven’t installed the Kaggle Python package needed to use the command line tool or generated an API token, check out the getting started steps first.

Some of the commands for interacting with Datasets via CLI include:

- `kaggle datasets list -s [KEYWORD]`: list datasets matching a search term
- `kaggle datasets download -d [DATASET]`: download files associated with a dataset

If you are creating or updating a dataset on Kaggle, you can also use the API to make maintenance convenient or even programmatic. View all available commands on the official documentation on GitHub [here](https://github.com/Kaggle/kaggle-api#datasets) and keep up-to-date with the latest features and bug fixes in the [changelog](https://github.com/Kaggle/kaggle-api/blob/master/CHANGELOG.md).

To explore additional CLI arguments, remember that you can always append `-h` after any call to see the help menu for that command.

Other than the Kaggle API, there is also a Kaggle connector on DataStudio! [Here](https://datastudio.google.com/datasources/create?connectorId=AKfycbz8WVuZI1FRHJM3g_ucqP-L7B9EIIPDsC9RofvZk1Xw-bD6p55SNjs7JudEsOYK1o2t) You can select Kaggle Datasets as a data source to import directly into DataStudio. Work in DataStudio to easily create beautiful and effective dashboards on Kaggle Datasets!

# Creating and Maintaining Datasets

The Kaggle API can be used to create new Datasets and Dataset versions on Kaggle from the comfort of the command-line. This can make sharing data and projects on Kaggle a simple part of your workflow. You can even use the API plus a tool like crontab to schedule programmatic updates of your Datasets to keep them well maintained.

If you haven’t installed the Kaggle Python package needed to use the command line tool or generated an API token, check out the getting started steps first.

## Create a New Dataset

Here are the steps you can follow to create a new dataset on Kaggle:

1. Create a folder containing the files you want to upload
2. Run `kaggle datasets init -p /path/to/dataset` to generate a metadata file [here](https://github.com/Kaggle/kaggle-api/wiki/Dataset-Metadata)
3. Add your dataset’s metadata to the generated file, `datapackage.json`
4. Run `kaggle datasets create -p /path/to/dataset` to create the dataset

Your dataset will be private by default. You can also add a `-u` flag to make it public when you create it, or navigate to “Settings” > “Sharing” from your dataset’s page to make it public or share with collaborators.

## Create a New Dataset Version

If you’d like to upload a new version of an existing dataset, follow these steps:

1. Run `kaggle datasets init -p /path/to/dataset` to generate a metadata file [here](https://github.com/Kaggle/kaggle-api/wiki/Dataset-Metadata) (if you don’t already have one)
2. Make sure the `id` field in `dataset-metadata.json` (or `datapackage.json`) points to your dataset
3. Run `kaggle datasets version -p /path/to/dataset -m "Your message here"`

These instructions are the basic commands required to get started with creating and updating Datasets on Kaggle. You can find out more details from the official documentation on GitHub:

- Initializing metadata [here](https://github.com/Kaggle/kaggle-api#initialize-metadata-file-for-dataset-creation)
- Create a Dataset [here](https://github.com/Kaggle/kaggle-api#create-a-new-dataset)
- Update a Dataset [here](https://github.com/Kaggle/kaggle-api#create-a-new-dataset-version)

## Working with Dataset Metadata

If you want a faster way to complete the required `dataset-metadata.json` file (for example, if you want to add column-level descriptions for many tabular data files), we recommend using Frictionless Data’s Data Package Creator [here](http://create.frictionlessdata.io/). Simply upload the `dataset-metadata.json` file that you’ve initialized for your dataset, fill out metadata in the user interface, and download the result.

To explore some further CLI arguments, remember that you can always append `-h` after any call to see the help menu for that command.