datagouv-cli is a command-line tool for data.gouv.fr: work with datasets, organizations, resources, and topics from your terminal. The command is datagouv.
Install it on Linux, macOS, or Windows β no other dependency required.
curl -fsSL https://raw.githubusercontent.com/datagouv/datagouv-cli/main/scripts/install.sh | bashDownload the archive for your platform from GitHub Releases and install it on your PATH:
# Linux / macOS
curl -LO https://github.com/datagouv/datagouv-cli/releases/latest/download/datagouv-$(uname -s | tr '[:upper:]' '[:lower:]' | sed 's/darwin/macos/')-$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz
tar -xzf datagouv-*.tar.gz
sudo install -d /usr/local/lib/datagouv
sudo cp -a datagouv/. /usr/local/lib/datagouv/
sudo ln -sf /usr/local/lib/datagouv/datagouv /usr/local/bin/datagouv# Windows
Invoke-WebRequest -Uri https://github.com/datagouv/datagouv-cli/releases/latest/download/datagouv-windows-amd64.zip -OutFile datagouv-windows-amd64.zip
Expand-Archive datagouv-windows-amd64.zip -DestinationPath .
$installDir = "$env:LOCALAPPDATA\Programs\datagouv"
New-Item -ItemType Directory -Force -Path $installDir | Out-Null
Copy-Item -Recurse -Force datagouv\* $installDir
$env:Path += ";$installDir"
[Environment]::SetEnvironmentVariable("Path", $env:Path, "User")sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://datagouv.github.io/datagouv-cli/datagouv.gpg \
| sudo gpg --dearmor -o /etc/apt/keyrings/datagouv.gpg
echo "deb [signed-by=/etc/apt/keyrings/datagouv.gpg] https://datagouv.github.io/datagouv-cli stable main" \
| sudo tee /etc/apt/sources.list.d/datagouv.list
sudo apt update && sudo apt install datagouvbrew tap datagouv/datagouv-cli https://github.com/datagouv/datagouv-cli.git
brew trust datagouv/datagouv-cli
brew install datagouvFrom a GitHub Release (replace vX.Y.Z with the desired version):
choco install datagouv --source="https://github.com/datagouv/datagouv-cli/releases/download/vX.Y.Z"datagouv setup
datagouv dataset get <dataset-id>datagouv --helpFirst set up your config:
datagouv setupYou will be asked the environment you want to interact with, and your API key. They will be stored in a config file in your home directory. If you only intend to get data, you may leave the API key blank.
Note: you may skip this setup step if you intend to target the production platform and fetch data.
To reset your settings, delete the config file with datagouv delete-config.
All objects have a display command that shows the object's main metadata in a human-readable way:
datagouv organization display "534fff81a3a7292c64a77e5c"
> badges: [{'kind': 'public-service'}, {'kind': 'certified'}]
> ββββββββββββββββββββ
> business_number_id: 12002701600563
> ββββββββββββββββββββ
> created_at: 2014-04-17T18:21:21.523000+00:00
> ...All objects also have a get command, that outputs all the object's metadata in JSON (directly fed from datagouv's API). You may for instance give the output to jq like:
datagouv organization get "534fff81a3a7292c64a77e5c" | jq .name
> "Institut national de la statistique et des Γ©tudes Γ©conomiques (Insee)"If you have run the setup command and filled in your API key, you may interact with objects (according to your rights on the platform), for instance:
datagouv dataset create --title "New dataset" --description "Nice description" --organization_id "646b7187b50b2a93b1ae3d45"
> Dataset created successfully β id is 69fb46c2bdeef492539acd61
# use the `--set` argument to update keys (can be used multiple times in one call)
datagouv dataset update "69fb46c2bdeef492539acd61" --set title="New title" --set private=true
> Dataset updated successfully β
datagouv resource create "69fb46c2bdeef492539acd61" "First resource" --file-to-upload file.csv --set type=main
> Resource created successfully β id is 49e370df-cd09-4792-915b-95d25c2adc08
datagouv resource delete "49e370df-cd09-4792-915b-95d25c2adc08"
> Resource deleted successfully βThe --help flag is available for all subcommands.
For programmatic access to the data.gouv.fr API, see datagouv_client.
This project uses Python >=3.10,<3.15 and uv to manage dependencies.
uv sync --dev
uv run datagouv --helpBuild a local binary:
uv run pyinstaller packaging/pyinstaller/datagouv.spec --clean --noconfirm
./dist/datagouv/datagouv --helpBefore contributing to the repository and making any PR, it is necessary to initialize the pre-commit hooks:
uv sync --dev
uv run pre-commit installOnce this is done, code formatting and linting, as well as import sorting, will be automatically checked before each commit.
If you cannot use pre-commit, it is necessary to format, lint, and sort imports with Ruff for linting and formatting. Either running these commands manually or installing the pre-commit hook is required before submitting contributions.
uv run ruff check --fix && uv run ruff formatSee RELEASING.md.