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§
- Grpc
Call Options - Per-request profile, outcome, and optional enclosing budget.
- Grpc
Deadline Error - Stable, payload-free gRPC deadline classification.
- Grpc
Enclosing Deadline - An optional absolute budget supplied by an enclosing workflow.
- Grpc
Stream Deadline - Established-stream idle and lifetime controller.
- Grpc
Timeout Policy - Logical gRPC deadlines applied by an Anytype gRPC client.
- Grpc
Transport Progress - Raw response-body progress shared with an established stream controller.
Enums§
- Grpc
Stream Error - Error returned while waiting for established-stream progress.
- Grpc
Timeout Class - Closed logical gRPC deadline taxonomy.
- Grpc
Timeout Config Error - Invalid logical gRPC deadline configuration.
- Grpc
Timeout Outcome - Effect of a gRPC timeout on an operation.
- Grpc
Timeout Source - 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
AnytypeErroras the default error.