data-gov-ckan
Async Rust client for CKAN APIs. Typed models, ergonomic helpers, works with any CKAN-compatible portal.
⚠️ data.gov no longer uses CKAN
As of 2026 the data.gov catalog is served by a purpose-built Catalog API — see the
data-gov-catalogcrate in this workspace.This crate is retained, not deprecated. CKAN still powers many other open-data portals (European, state, municipal, and university instances) and the client works unchanged against any compliant CKAN deployment — just point
Configuration::base_pathat your target host.Maintenance status. Active workspace development now focuses on the Catalog API.
data-gov-ckanwill continue to receive bug fixes and security patches, but new features are unlikely unless a contributor steps up. Issues and PRs are welcome.
Requirements
- Rust 1.90+ (Rust 2024 edition)
- Cargo and git
Install / depend
Use the published crate from crates.io:
[]
= "0.4"
= { = "1", = ["full"] }
Working inside this repository? Point to the local path instead: data-gov-ckan = { path = "../data-gov-ckan" }. If you need the bleeding edge between releases, swap in the git dependency form: data-gov-ckan = { git = "https://github.com/dspadea/data-gov-rs", package = "data-gov-ckan" }.
Highlights
- 🔁 Coverage of the common CKAN
action/*endpoints (package_search,package_show,organization_list,group_list,tag_list,user_list, and the matching autocomplete helpers) - ✅ Strongly typed models generated from the official OpenAPI spec
- 🌐 Configurable base URL, authentication, and user-agent handling
- ⚙️ Async support via
reqwest+tokio - 🧪 Wiremock-based unit tests plus optional live integration tests
Quick start
use ;
use Arc;
async
Custom configuration & auth
use ;
use Arc;
async
Filtering with Solr-style query strings:
let fq = r#"organization:"gsa-gov" AND res_format:"CSV""#;
let results = client.package_search.await?;
Solr query syntax
The q (full-text) and fq (filter query) parameters are passed directly to
CKAN's Solr-backed package_search endpoint. Typical patterns:
- Wildcards:
q=climat* - Phrase search:
q="air quality" - Fielded filters:
fq=organization:epa-gov AND res_format:CSV - Range queries:
fq=metadata_modified:[2020-01-01T00:00:00Z TO NOW]
Use fq for structured filtering and q for free-text searches. When building
fq strings programmatically, quote values containing spaces to ensure correct
Solr parsing.
API surface
Core methods include package_search, package_show, organization_list, group_list, tag_list, and user_list. Autocomplete helpers cover datasets, organisations, groups, tags, and users. Errors are surfaced through the CkanError enum with variants for request, parse, and API failures.
Development
Live-network integration tests are marked #[ignore] and target a CKAN
instance you configure (legacy data.gov fixtures are kept for historical
reference). Run them explicitly with cargo test -- --ignored.
Authentication options
- API keys: set
Configuration.api_key = Some(ApiKey { .. }) - Basic auth: populate
Configuration.basic_auth - Custom headers: configure the inner
reqwest::Clientbefore passing the configuration intoCkanClient
Reuse the same CkanClient for multiple requests to benefit from connection pooling. Combine async calls with tokio::try_join! for improved throughput.
Disclaimer & license
This is an independent project and is not affiliated with data.gov or any government agency. For authoritative information, refer to the official data.gov portal.
Licensed under the Apache License 2.0.