koios-sdk 0.1.1

A Rust SDK for the Koios Cardano API
Documentation
// lib.rs documentation update
//! Koios SDK - A Rust SDK for the Koios Cardano API
//!
//! This crate provides a strongly-typed client for interacting with the Koios API,
//! which provides access to Cardano blockchain data. Koios is a decentralized and
//! elastic RESTful query layer for exploring data on the Cardano blockchain.
//!
//! # Features
//!
//! - Strongly typed API client
//! - Support for multiple networks (Mainnet, Preprod, Preview, Guild)
//! - Authentication support (JWT Bearer tokens)
//! - Rate limiting
//! - Async/await support
//! - Comprehensive error handling
//! - Full coverage of Koios API endpoints
//!
//! # Example
//!
//! ```rust,no_run
//! use koios_sdk::{Client, Network, error::Result};
//!
//! #[tokio::main]
//! async fn main() -> Result<()> {
//!     // Create a client with default configuration (Mainnet)
//!     let client = Client::new()?;
//!
//!     // Or specify a different network
//!     let client = Client::builder()
//!         .network(Network::Preprod)
//!         .build()?;
//!
//!     // Get the current tip of the blockchain
//!     let tip = client.get_tip().await?;
//!     println!("Current tip: {:?}", tip);
//!
//!     Ok(())
//! }
//! ```
//!
//! # Network Selection
//!
//! The SDK supports multiple Cardano networks:
//!
//! ```rust,no_run
//! use koios_sdk::{Client, Network};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//!     // Connect to Preprod network
//!     let preprod_client = Client::builder()
//!         .network(Network::Preprod)
//!         .build()?;
//!
//!     // Connect to Preview network
//!     let preview_client = Client::builder()
//!         .network(Network::Preview)
//!         .build()?;
//!
//!     // Connect to Guild network
//!     let guild_client = Client::builder()
//!         .network(Network::Guild)
//!         .build()?;
//!
//!     Ok(())
//! }
//! ```
//!
//! # Authentication
//!
//! You can authenticate using a JWT Bearer token:
//!
//! ```rust,no_run
//! use koios_sdk::ClientBuilder;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//!     let client = ClientBuilder::new()
//!         .auth_token("your-jwt-token")
//!         .build()?;
//!
//!     Ok(())
//! }
//! ```
//!
//! # Rate Limiting
//!
//! The SDK includes built-in rate limiting:
//!
//! ```rust,no_run
//! use koios_sdk::ClientBuilder;
//! use governor::Quota;
//! use std::num::NonZeroU32;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//!     let client = ClientBuilder::new()
//!         .rate_limit(Quota::per_second(NonZeroU32::new(100).unwrap()))
//!         .build()?;
//!
//!     Ok(())
//! }
//! ```
//!
//! # Modules
//!
//! - [`client`] - Client implementation and builder
//! - [`api`] - API endpoint implementations
//! - [`models`] - Data models and types
//! - [`error`] - Error types and handling
//! - [`network`] - Network configuration and options

#![forbid(unsafe_code)]
#![warn(
    missing_debug_implementations,
    missing_copy_implementations,
    trivial_casts,
    trivial_numeric_casts,
    unused_import_braces,
    unused_qualifications,
    rust_2018_idioms
)]
#![allow(dead_code)]

pub mod api;
pub mod client;
pub mod error;
pub mod models;
pub mod network;
pub mod types;
mod utils;

pub use client::{Client, ClientBuilder};
pub use error::{Error, Result};
pub use network::Network;

/// Re-export of commonly used types
pub mod prelude {
    pub use crate::client::{Client, ClientBuilder};
    pub use crate::error::{Error, Result};
    pub use crate::models;
    pub use crate::network::Network;
    pub use crate::types::*;
}

// Version of the crate
pub const VERSION: &str = env!("CARGO_PKG_VERSION");

// API version supported by this SDK
pub const API_VERSION: &str = "v1";

// Default API URL
pub const DEFAULT_API_URL: &str = "https://api.koios.rest/api/v1";