mirror of
https://github.com/dathere/ckanaction.git
synced 2025-11-09 06:19:49 +00:00
🎁 Rust library crate featuring an API wrapper of the CKAN Action v3 API.
https://ckanaction.dathere.com
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| README.md | ||
ckanaction
Rust library crate to access CKAN Action API endpoints through Rust builders. Based on the CKAN Action API v3. Endpoints are expected to return with an output of type serde_json::Value.
Example
use dotenvy::dotenv;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Load environment variables from .env file
dotenv()?;
// Initialize and build CKAN struct
let ckan = ckanaction::CKAN::builder()
.url("http://localhost:5000")
.token(dotenvy::var("CKAN_API_TOKEN")?)
.build();
// Send request to /status_show and print output
let status_show = ckan.status_show().await?;
println!("{status_show:#?}");
Ok(())
}
Notes
- Add the
CKAN_API_TOKENenvironment variable to a.envfile where the program runs to include the token when making requests to the CKAN API. - If you use a
maybe_fn()then if you provideNoneit will be ignored and that parameter will not be added to the JSON body. This library assumesNonewould not be provided as a value (since the cases where it is a value is often the default value that the CKAN API already has set for that parameter).