Rust
Official Rust client for the Zernio API. Add the zernio crate and publish to 14+ social platforms with an async reqwest-based client.
The official Rust client for the Zernio API. Fully async, built on reqwest.
- Crate:
zernioon crates.io - Source: github.com/zernio-dev/zernio-rust
Install
cargo add zernio
cargo add tokio --features macros,rt-multi-threadQuick start
Endpoints are free functions grouped by module under zernio::apis. Every call takes a Configuration carrying your Bearer API key:
use zernio::apis::{configuration::Configuration, posts_api};
use zernio::models::{CreatePostRequest, CreatePostRequestPlatformsInner};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut config = Configuration::new();
config.bearer_access_token = Some(std::env::var("ZERNIO_API_KEY")?);
let request = CreatePostRequest {
content: Some("Hello world from Zernio!".to_string()),
platforms: Some(vec![
CreatePostRequestPlatformsInner::new("twitter".to_string(), "acc_xxx".to_string()),
CreatePostRequestPlatformsInner::new("linkedin".to_string(), "acc_yyy".to_string()),
]),
publish_now: Some(true),
..Default::default()
};
// The third argument is an optional x-request-id idempotency key.
let post = posts_api::create_post(&config, request, None).await?;
println!("{post:?}");
Ok(())
}Get your API key from the dashboard, or see Getting started for the full setup walkthrough.
For safe retries, pass a UUID as the x_request_id argument. Requests that reuse the same ID within ~5 minutes return the original post instead of double-posting.
Error handling
Every call returns Result<T, zernio::apis::Error<E>>, where E is the operation's typed error. API-level failures surface as Error::ResponseError with the status and raw body:
use zernio::apis::Error;
match posts_api::create_post(&config, request, None).await {
Ok(post) => println!("{post:?}"),
Err(Error::ResponseError(resp)) => {
eprintln!("API error {}: {}", resp.status, resp.content);
}
Err(e) => eprintln!("transport error: {e}"),
}See the error handling guide for the API's error codes and retry semantics.
Full reference
The crate exposes every API namespace as a module: posts_api, accounts_api, profiles_api, analytics_api, queue_api, media_api, webhooks_api, ads_api, phone_numbers_api, whats_app_api, workflows_api, and more. Each function maps 1:1 to an API Reference operation.