Skip to main content

Crate anytype

Crate anytype 

Source
Expand description

§Anytype Rust API client

The anytype crate provides a fluent Rust client for Anytype automation. AnytypeClient combines the public HTTP API with selected anytype-heart gRPC capabilities behind one client and one credential store.

§Transport and coverage

Direct HTTP support covers authentication, spaces, types, properties, tags, objects, templates, views, members, search, basic file transfer, and space-scoped chats for API version ANYTYPE_API_VERSION. gRPC supplies capabilities that HTTP does not expose or represents with less fidelity, including rich file operations, structured chat messages and streams, typed body blocks, archived-object cleanup, space backup, and process watching.

HTTP calls require an access token. gRPC calls require an account key or session token. KeyStore stores both credential families. The crate has no default Cargo features; its optional features expose test fixtures only.

§Quick start

use anytype::prelude::*;

let client = AnytypeClient::new("my-app")?;
let spaces = client.spaces().list().await?;
let Some(space) = spaces.iter().next() else {
    return Ok(());
};

let page = client
    .new_object(&space.id, "page")
    .name("Meeting notes")
    .body("# Decisions")
    .create()
    .await?;

let results = client
    .search_in(&space.id)
    .text("meeting notes")
    .types(["page", "note"])
    .sort_desc("last_modified_date")
    .limit(10)
    .execute()
    .await?;
for object in results.iter() {
    println!("{}", object.name.as_deref().unwrap_or("(unnamed)"));
}

client.object(&space.id, &page.id).delete().await?;

§Builder API

Methods on AnytypeClient return request builders. Builder setters configure a request, and a terminal verb such as get, list, create, update, delete, or execute sends it. Entity APIs use consistent entry points: plural names list values, singular names address one value, new_* creates values, and update_* modifies them.

use anytype::prelude::*;

let object = client.object("space_id", "object_id").get().await?;
let objects = client.objects("space_id")
    .filter(Filter::type_in(["page"]))
    .limit(50)
    .list().await?;
let space = client.new_space("Project")
    .description("Project documents")
    .create().await?;

List operations return PagedResult or PaginatedResponse values with stream and collection helpers. Filter constructors preserve typed number and checkbox values and reject invalid operator combinations before dispatch.

§Secret-safe HTTP diagnostics

HTTP tracing is metadata-only at every logging level. The anytype::http target reports a stable error variant plus status, validated method, and bounded path-only context when available. The anytype::http_json trace target reports only method, sanitized path, field counts, and byte counts. Neither target emits request or response bodies, query values, headers, full URLs, or credentials. This trace-level guarantee applies only to these library-owned HTTP targets; other anytype targets are outside its scope and require an application filter appropriate to their data.

Standard AnytypeError Display and Debug formatting and its standard error source chain are also classification-oriented and secret-safe across all variants. Raw public fields remain available through explicit variant matching, so applications must not forward those values to diagnostics without their own policy.

Use AnytypeError::diagnostic when forwarding an error to application diagnostics:

tracing::warn!(error = %error.diagnostic(), "Anytype request failed");

Modules§

attached_discussions
Typed discovery and idempotent creation of discussions attached to objects.
auth
Anytype client authentication
body
Typed, bounded, fail-closed body-block reads.
body_mutation
Verified, typed mutations for rich document body blocks.
body_rpc
Finite, payload-free lifecycle controls for body-block gRPC operations.
cache
Anytype cache
chat_stream
Anytype Chat Streaming (gRPC)
chats
Anytype Chats
client
Anytype Rust API Client
error
Errors returned by AnytypeClient
files
Anytype Files
filters
Filters and sorting
keystore
Secure storage for API keys and credentials
members
Anytype Members
objects
Anytype Objects
paged
Paginated and Stream results for list and search methods.
prelude
Prelude module - import (nearly) all the things with use anytype::prelude::*;
process_watcher
Process Watcher (gRPC)
properties
Anytype Properties
resolve
Name and id resolution
search
Anytype Search
spaces
Anytype Spaces
tags
Anytype Tags
templates
Anytype Templates
types
Anytype Types
validation
Validation functions
verify
Verification helpers for eventual consistency.
views
Anytype Views (for Collections and Queries)

Structs§

GrpcCallOptions
Per-request profile, outcome, and optional enclosing budget.
GrpcDeadlineError
Stable, payload-free gRPC deadline classification.
GrpcEnclosingDeadline
An optional absolute budget supplied by an enclosing workflow.
GrpcStreamDeadline
Established-stream idle and lifetime controller.
GrpcTimeoutPolicy
Logical gRPC deadlines applied by an Anytype gRPC client.
GrpcTransportProgress
Raw response-body progress shared with an established stream controller.

Enums§

GrpcStreamError
Error returned while waiting for established-stream progress.
GrpcTimeoutClass
Closed logical gRPC deadline taxonomy.
GrpcTimeoutConfigError
Invalid logical gRPC deadline configuration.
GrpcTimeoutOutcome
Effect of a gRPC timeout on an operation.
GrpcTimeoutSource
Origin of an observed gRPC deadline expiration.

Constants§

ANYTYPE_API_VERSION
API version
ANYTYPE_DESKTOP_URL
API endpoint (localhost desktop client)
ANYTYPE_GRPC_TIMEOUT_SECS
Process environment variable that overrides inherited gRPC deadlines.
ANYTYPE_HEADLESS_URL
API endpoint (CLI/headless server)

Functions§

scope_grpc_deadline
Runs all nested gRPC calls under one absolute caller-owned deadline.

Type Aliases§

Result
Result type alias using AnytypeError as the default error.