WindowsmacOSLinux

Where Is the Kaggle API Key Stored?

Your Kaggle API key lives in a kaggle.json file inside a .kaggle folder in your home directory, on Windows, macOS, and Linux.

Last updated

The Kaggle CLI and API client read one small credentials file and nothing else. Download it from your Kaggle account page (Create New API Token) and drop it into a folder named .kaggle inside your home directory. The tools create nothing for you, so make the folder yourself first.

Permissions matter more than people expect. The file holds a live API key, so lock it down to owner read only after placing it. On CI servers and containers skip the file entirely and export the username and key as environment variables, which the CLI accepts as an override.

Where Kaggle stores this, by platform

Windows
C:\Users\[Username]\.kaggle\kaggle.json

Create the folder first, then move the downloaded file in. Lock it with owner read only permissions. Set KAGGLE_CONFIG_DIR to point elsewhere on shared or CI machines.

macOS
~/.kaggle/kaggle.json

Same layout as Linux. Create ~/.kaggle, move the file in, and chmod it to 600. The CLI checks this exact path unless the config dir variable is set.

Linux
~/.kaggle/kaggle.json

Identical to macOS. Colab and server users hit the same unauthorized error when the file lands in the wrong home, so confirm which user runs the command before debugging further.

Frequently asked questions

The Kaggle CLI says unauthorized even though kaggle.json exists. What now?

The token is wrong, expired, or in the wrong folder. Recreate it from your Kaggle account settings page, place the fresh file at the path above, and set its permissions to owner read only. On shared machines prefer the username and key environment variables instead.

Where do Kaggle downloads go by default?

The current working directory, unless you pass a download directory flag. Competition files land where you ran the command, so make one folder per competition if you want to stay sane.

Notice an outdated path? Let us know.