peasy-document 0.2.3

Rust client for PeasyDocument — document format tools, glossary, and guides API
Documentation

peasy-document

crates.io docs.rs License: MIT crates.io GitHub stars

Async Rust client for the PeasyFormats API -- convert between Markdown, JSON, YAML, CSV, and other document formats with tools for format identification, MIME type lookup, and structured data transformation. Built with reqwest, serde, and tokio.

Built from PeasyFormats, a comprehensive document conversion toolkit offering free online tools for transforming between structured data formats. The glossary covers document formats from lightweight Markdown to structured JSON and YAML, while guides explain format conversion strategies and encoding best practices.

Try the interactive tools at peasyformats.com -- Markdown to HTML, YAML/JSON Converter, Format Identifier, and more.

Table of Contents

Install

[dependencies]
peasy-document = "0.2.0"
tokio = { version = "1", features = ["full"] }

Or via cargo:

cargo add peasy-document

Quick Start

use peasy_document::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();

    // List available document tools
    let tools = client.list_tools(&Default::default()).await?;
    for tool in &tools.results {
        println!("{}: {}", tool.name, tool.description);
    }

    Ok(())
}

What You Can Do

Document Conversion Tools

Document format conversion is a core workflow for developers, data engineers, and content authors. Converting Markdown to HTML powers static site generators and documentation systems. Transforming JSON to YAML (and vice versa) is essential for configuration management across Kubernetes, Docker Compose, and CI/CD pipelines. CSV-to-JSON conversion bridges the gap between spreadsheet data and web APIs.

Tool Description Use Case
Markdown to HTML Convert Markdown syntax to semantic HTML Static sites, documentation pipelines
YAML/JSON Converter Bidirectional YAML and JSON transformation Kubernetes configs, API payloads
Format Identifier Detect file format from content or extension File upload validation, data pipelines
use peasy_document::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();

    // Fetch the Markdown to HTML conversion tool
    let tool = client.get_tool("markdown-to-html").await?;
    println!("Tool: {}", tool.name);           // Markdown to HTML converter
    println!("Category: {}", tool.category);   // Document conversion category

    // List supported document formats and their MIME types
    let formats = client.list_formats(&Default::default()).await?;
    for fmt in &formats.results {
        println!(".{} -- {} ({})", fmt.extension, fmt.name, fmt.mime_type);
    }

    // List available format conversions from JSON
    let conversions = client.list_conversions(&peasy_document::ListConversionsOptions {
        source: Some("json".into()),
        ..Default::default()
    }).await?;
    println!("Found {} conversion paths from JSON", conversions.results.len());

    Ok(())
}

Learn more: Markdown to HTML Tool · YAML/JSON Converter · File Format Conversion Guide

Browse Document Format Reference

The document format glossary provides clear definitions for structured data formats, markup languages, and serialization standards. Understanding the differences between JSON and YAML syntax, when CSV is preferable to JSON for tabular data, and how Markdown flavors (CommonMark, GFM) differ helps developers choose the right format for each use case.

Glossary Term Description
Markdown Lightweight markup language for creating formatted text with plain-text syntax
CSV Comma-separated values format for tabular data interchange
JSON JavaScript Object Notation for structured data serialization
YAML Human-readable data serialization format used in configuration files
// Browse document format glossary terms
let glossary = client.list_glossary(&peasy_document::ListOptions {
    search: Some("csv".into()),
    ..Default::default()
}).await?;
for term in &glossary.results {
    println!("{}: {}", term.term, term.definition); // Document format definition
}

// Read in-depth guides on format conversion strategies
let guides = client.list_guides(&peasy_document::ListGuidesOptions {
    category: Some("document".into()),
    ..Default::default()
}).await?;
for guide in &guides.results {
    println!("{} ({})", guide.title, guide.audience_level); // Guide title and difficulty
}

Learn more: Markdown Glossary · JSON Glossary · How to Convert Markdown to Other Formats

Search and Discovery

The unified search endpoint queries across all document tools, glossary terms, guides, and supported file formats simultaneously. This is useful for building editor plugins, documentation search, or data pipeline tools that need to discover conversion capabilities.

// Search across all document tools, glossary, and guides
let results = client.search("markdown", Some(20)).await?;
println!("Found {} tools, {} glossary terms",
    results.results.tools.len(),
    results.results.glossary.len()); // Cross-content document format search results

Learn more: CSV Glossary · YAML Glossary · All Document Guides

API Client

The client wraps the PeasyFormats REST API with strongly-typed Rust structs using serde deserialization.

use peasy_document::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    // Or with a custom base URL:
    // let client = Client::with_base_url("https://custom.example.com");

    // List tools with filters
    let opts = peasy_document::ListOptions {
        page: Some(1),
        limit: Some(10),
        search: Some("markdown".into()),
        ..Default::default()
    };
    let tools = client.list_tools(&opts).await?;

    // Get a specific tool
    let tool = client.get_tool("markdown-to-html").await?;
    println!("{}: {}", tool.name, tool.description);

    // Search across all content
    let results = client.search("markdown", Some(20)).await?;
    println!("Found {} tools", results.results.tools.len());

    // Browse the glossary
    let glossary = client.list_glossary(&peasy_document::ListOptions {
        search: Some("csv".into()),
        ..Default::default()
    }).await?;
    for term in &glossary.results {
        println!("{}: {}", term.term, term.definition);
    }

    // Discover guides
    let guides = client.list_guides(&peasy_document::ListGuidesOptions {
        category: Some("document".into()),
        ..Default::default()
    }).await?;
    for guide in &guides.results {
        println!("{} ({})", guide.title, guide.audience_level);
    }

    // List format conversions
    let conversions = client.list_conversions(&peasy_document::ListConversionsOptions {
        source: Some("json".into()),
        ..Default::default()
    }).await?;

    Ok(())
}

Available Methods

Method Description
list_tools(&opts) List tools (paginated, filterable)
get_tool(slug) Get tool by slug
list_categories(&opts) List tool categories
list_formats(&opts) List file formats
get_format(slug) Get format by slug
list_conversions(&opts) List format conversions
list_glossary(&opts) List glossary terms
get_glossary_term(slug) Get glossary term
list_guides(&opts) List guides
get_guide(slug) Get guide by slug
list_use_cases(&opts) List use cases
search(query, limit) Search across all content
list_sites() List Peasy sites
openapi_spec() Get OpenAPI specification

Full API documentation at peasyformats.com/developers/. OpenAPI 3.1.0 spec: peasyformats.com/api/openapi.json.

Learn More About Document Formats

Also Available

Language Package Install
Python peasy-document pip install "peasy-document[all]"
TypeScript peasy-document npm install peasy-document
Go peasy-document-go go get github.com/peasytools/peasy-document-go
Ruby peasy-document gem install peasy-document

Peasy Developer Tools

Part of the Peasy Tools open-source developer ecosystem.

Package PyPI npm crates.io Description
peasy-pdf PyPI npm crate PDF merge, split, rotate, compress -- peasypdf.com
peasy-image PyPI npm crate Image resize, crop, convert, compress -- peasyimage.com
peasy-audio PyPI npm crate Audio trim, merge, convert, normalize -- peasyaudio.com
peasy-video PyPI npm crate Video trim, resize, thumbnails, GIF -- peasyvideo.com
peasy-css PyPI npm crate CSS minify, format, analyze -- peasycss.com
peasy-compress PyPI npm crate ZIP, TAR, gzip compression -- peasytools.com
peasy-document PyPI npm crate Markdown, HTML, CSV, JSON conversion -- peasyformats.com
peasytext PyPI npm crate Text case conversion, slugify, word count -- peasytext.com

Embed Widget

Embed PeasyDocument widgets on any website with peasy-document-embed:

<script src="https://cdn.jsdelivr.net/npm/peasy-document-embed@1/dist/embed.min.js"></script>
<div data-peasydocument="entity" data-slug="example"></div>

Zero dependencies · Shadow DOM · 4 themes (light/dark/sepia/auto) · Widget docs

License

MIT