anytype 0.2.7

An ergonomic Anytype API client in rust
Documentation
// Lists templates for a type in the current space.

use anytype::prelude::*;

#[tokio::main]
async fn main() -> Result<(), AnytypeError> {
    let client = AnytypeClient::new(env!("CARGO_BIN_NAME"))?.env_key_store()?;
    let space_id = anytype::test_util::example_space_id(&client).await?;

    let page_type = client.lookup_type_by_key(&space_id, "page").await?;

    let templates = client.templates(&space_id, &page_type.id).list().await?;
    println!(
        "Type '{}' has {} templates",
        page_type.key,
        templates.items.len()
    );

    for template in templates.iter() {
        println!(
            "- {} ({})",
            template.name.as_deref().unwrap_or("(unnamed)"),
            template.id
        );
    }

    Ok(())
}