Website: English · Deutsch — command reference, guides and API docs
Browse Germany's central open-data catalogue from your terminal. govdata is a
command-line tool over the GovData CKAN Action API
(ckan.govdata.de) — the national portal that federates open datasets from
federal government, federal states and municipalities: search, inspect, filter
and pipe straight into jq.
--compact
for one-line/scripting.search, package, packages, organizations,
organization, groups, group, tags, resource, and a generic action
escape hatch.Want to use this as a TypeScript library or understand how it's built? See DEVELOPING.md.
npm i -g @maschinenlesbar.org/govdata-cli
This installs the govdata command. Requires Node.js 20+.
Check it works:
govdata --help
No setup needed — the API is open and requires no key. Your first search:
govdata search Haushalt --rows 5
The result is unwrapped from CKAN's { help, success, result } envelope — you
get the search object directly: { count, results, sort, … }. Pull out just
the titles with jq:
govdata search Haushalt --rows 5 | jq '{count, titles: [.results[].title]}'
Take a name from those results and fetch the full dataset record:
govdata package luftqualitat
search [query] [filters…] search datasets
package <id> show one dataset by id or name
packages [--limit <n>] [--offset <n>] list dataset names
organizations [--all-fields] list organizations (publishers)
organization <id> show one organization
groups [--all-fields] list groups (themes/categories)
group <id> show one group
tags [--query <substring>] list tags
resource <id> show one resource (distribution)
action <name> [--param key=value …] call any CKAN action (generic)
search filters| Flag | Meaning |
|---|---|
[query] |
free-text Solr query, e.g. Haushalt or title:Klimaschutz |
--fq <filter> |
Solr filter query, e.g. groups:tran (repeatable; every filter must match) |
--rows <n> |
max results to return |
--start <n> |
zero-based offset for paging |
--sort <expr> |
Solr sort expression, e.g. metadata_modified desc |
Note on
--rows— GovData's Solr caps a single search at 1000 results server-side. Asking for more (e.g.--rows 100000) is not an error — you simply get at most 1000 back, whilecountstill reports the true total. Use--startto page beyond the first 1000.
Note on free-text matching — the bare
[query]is a Solr query, and Solr tokenises terms: a string likeabc12345can match a dataset whose title contains12345(e.g.1,2,3,4,5 …). If you need an exact field match, scope the query (title:Klimaschutz) or add an--fqfilter rather than relying on a bare keyword.
packages flags| Flag | Meaning |
|---|---|
--limit <n> |
max names to return |
--offset <n> |
number of records to skip |
organizations / groups flag| Flag | Meaning |
|---|---|
--all-fields |
return full objects instead of bare names |
tags flag| Flag | Meaning |
|---|---|
--query <substring> |
filter tags by substring |
action flag| Flag | Meaning |
|---|---|
--param <key=value> |
query parameter (repeatable; duplicate keys are rejected) |
Note on the
<name>— the action name is validated client-side against^[a-z0-9_]+$(lowercase letters, digits and underscores). Names with dashes, uppercase letters or spaces are rejected before any request is sent — this keeps the escape hatch from injecting extra path segments into the request URL. Use the exact CKAN action name, e.g.package_search,organization_list,status_show.
The Glossary decodes every CKAN term and search-parameter name.
A few recipes to get going — see Usage.md for the full, use-case-driven set.
# Newest datasets first
govdata search Klima --rows 10 --sort "metadata_modified desc"
# Filter by publisher and file format (formats come as a bare string and an EU URI)
govdata search --fq organization:statistisches-bundesamt \
--fq 'res_format:("CSV" OR "http://publications.europa.eu/resource/authority/file-type/CSV")'
# Full dataset with all its resources (distributions)
govdata package luftqualitat | jq '.resources[] | {name, format, url}'
# All data publishers (short names)
govdata organizations
# Full publisher objects, then drill into one
govdata organizations --all-fields | jq '.[] | {name, title, packages: .package_count}'
govdata organization statistisches-bundesamt | jq '{title, package_count}'
# Tags matching a substring
govdata tags --query energie
# Any CKAN action not covered by a dedicated command
govdata action package_search --param q=Verkehr --param rows=3
Every command prints the unwrapped result as pretty JSON to stdout.
Errors and diagnostics go to stderr, so piping stdout into jq stays clean.
# Total datasets in the catalogue
govdata action package_search --param rows=0 | jq '.count'
# Resource format and download URL from a dataset
govdata package luftqualitat | jq '.resources[] | {format, url}'
# Discover a valid dataset name from a search hit
govdata search Luftqualität --rows 1 | jq -r '.results[0].name'
Use --compact for single-line JSON in pipelines and logs:
govdata --compact search Haushalt --rows 5 | jq -c '.results[].title'
--compact (and every global option) works before or after the command —
both govdata --compact search … and govdata search … --compact do the same
thing.
Exit codes make the CLI easy to use in scripts:
| Code | Meaning |
|---|---|
0 |
success (also --help / --version) |
4 |
dataset/resource not found (404) |
1 |
any other error — bad usage, CKAN success:false, network failure |
command not found: govdata — the global npm bin directory isn't on your
PATH. Run npm bin -g to find it and add it, or run via
npx @maschinenlesbar.org/govdata-cli ….4 / "not found" — the dataset or resource id doesn't exist or has
been removed. Re-run a search to get a fresh name/id.1 / CKAN success:false — the catalogue rejected the request
(malformed filter, unknown action name, etc.). Check your --fq syntax or
--param values.--timeout 60000.results — the search matched nothing; broaden the keyword, drop
an --fq filter, or check spelling.These apply to every command and may be given before or after it:
| Option | Description |
|---|---|
-V, --version |
Print the version number |
-h, --help |
Show help for the program or a command |
--compact |
Print JSON on a single line instead of pretty-printed |
--base-url <url> |
API base URL (default https://ckan.govdata.de) |
--timeout <ms> |
Per-request timeout (default 30000; at most 2147483647) |
--user-agent <ua> |
User-Agent header value |
--max-retries <n> |
Retries for transient 429/503 responses (default 2) |
--max-response-bytes <n> |
Cap response body size in bytes (0 = unlimited; default 100 MiB) |
This CLI is a client — it accesses data it does not own or redistribute. The upstream data is © its provider and licensed separately from this tool's code. See DATA_LICENSE.md.
GovData — catalogue metadata is Datenlizenz Deutschland Zero 2.0 (≈ CC0, no attribution). Each linked dataset has its own license set by its publisher — always check the dataset's
dct:licensebefore reusing its contents.
Dual-licensed — use it under either:
See LICENSING.md for details, and CONTRIBUTING.md for the contribution policy (this project does not accept external code contributions). Commercial enquiries: sebs@2xs.org.