From 02915feb1c6c0d44c7961208121c68a00cb64ca3 Mon Sep 17 00:00:00 2001 From: rzmk <30333942+rzmk@users.noreply.github.com> Date: Thu, 1 May 2025 15:53:09 -0400 Subject: [PATCH] docs: improve examples and clarification about status_show --- README.md | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 50e1e99..971ce42 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Rust library crate to access CKAN Action API endpoints through Rust builders. Ba ## Examples -Run `/status_show` endpoint for a CKAN instance and print the output: +Run `/package_list` endpoint with a limit of 5 results per page and print the output: ```rust use dotenvy::dotenv; @@ -20,9 +20,12 @@ async fn main() -> Result<(), Box> { .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:#?}"); + // Send request to /package_list and print output + let result = ckan.package_list() + .limit(5) // <-- This is an optional parameter you can remove + .call() + .await?; + println!("{result:#?}"); Ok(()) } @@ -30,13 +33,6 @@ async fn main() -> Result<(), Box> { > The following examples won't include the boilerplate code. -List packages: - -```rust -let result = ckan.package_list().call().await?; -println!("{result:#?}"); -``` - Create a new package (dataset) with custom fields: ```rust @@ -69,6 +65,13 @@ let result = ckan println!("{result:#?}"); ``` +Some endpoints without any parameters may not need a builder such as `/status_show` so there is no need to run `.call()` on `.status_show()`: + +```rust +let status_show = ckan.status_show().await?; +println!("{status_show:#?}"); +``` + ## Notes - Add the `CKAN_API_TOKEN` environment variable to a `.env` file where the program runs to include the token when making requests to the CKAN API.