data-gov
High-level Rust client and CLI for data.gov. It wraps the low-level data-gov-ckan crate with download helpers, an interactive REPL, and ergonomic configuration.
Requirements
- Rust 1.85+ (Rust 2024 edition)
- Cargo and git
Add to your project
Use the published crate from crates.io:
[]
= "0.1.1"
= { = "1", = ["full"] }
Working inside this repository? You can still use a path dependency in Cargo.toml:
= { = "../data-gov" }
Need unreleased features between tags? Swap in the git dependency form instead:
= { = "https://github.com/dspadea/data-gov-rs", = "data-gov" }
CLI install
The data-gov binary is then available on your PATH.
Highlights
- 🔍 Search data.gov with optional organization / format filters
- 📦 Retrieve dataset metadata and enumerate downloadable resources
- ⬇️ Download individual resources or entire datasets with progress bars
- 🏛️ List organisations and query autocomplete endpoints
- 🖥️ Interactive REPL with colour-aware output and shebang-friendly scripts
Library quick start
use DataGovClient;
async
CLI overview
data-gov search "climate change" 5
data-gov show electric-vehicle-population-data
data-gov download electric-vehicle-population-data 0
data-gov list organizations
Key defaults:
- Interactive mode:
data-govlaunches a REPL that stores downloads under~/Downloads/<dataset>/ - Non-interactive mode: Commands run directly in your current directory (
./<dataset>/) - Override download location with
--download-dir, toggle colours with--color, and silence progress bars viaNO_PROGRESS=1
Command reference
| Command | Purpose |
|---|---|
search <query> [limit] |
Full-text search with optional result cap |
show <dataset_id> |
Inspect dataset details and resources |
download <dataset_id> [index] |
Download all resources or a specific resource by index |
list organizations |
List publishing organisations |
setdir <path> |
Change the active download directory (REPL only) |
info |
Display current configuration |
help, quit |
Help and exit commands |
Automation
The REPL accepts stdin, so shebang scripts work out of the box:
#!/usr/bin/env data-gov
# Simple automation example
See ../examples/scripting for ready-made scripts such as download-epa-climate.sh and list-orgs.sh.
Configuration
use ;
let config = new
.with_mode
.with_download_dir
.with_api_key
.with_max_concurrent_downloads
.with_progress;
let client = with_config?;
Configuration covers the underlying CKAN settings, download directory logic, concurrency, progress output, and colour preferences.
Development
The crate re-exports data-gov-ckan as data_gov::ckan, making the lower-level client available when you need direct CKAN access.
Contributing & license
- Fork, branch, add tests, run
cargo test, open a PR - Licensed under Apache 2.0
⚠️ AI-assisted code: Significant portions of this crate were generated with AI tooling. While the library behaves well in ad-hoc testing, it still needs careful human review and polish before production use.