Expand description
A small async client for interacting with the Paperless-ngx API.
This crate provides PaperlessClient for talking to a Paperless instance and
convenience types for working with documents, tags, custom fields, correspondents,
document types, and tasks.
§Getting started
Create a client with your Paperless base URL and API token:
use paperless_api::PaperlessClient;
let client = PaperlessClient::new(
"https://paperless.example.com",
"your-api-token",
None,
)?;§Refreshing cached metadata
The client keeps some metadata cached locally, such as tags, custom fields, correspondents, and document types.
You can refresh individual caches:
use paperless_api::PaperlessClient;
let mut client = PaperlessClient::new(
"https://paperless.example.com",
"your-api-token",
None,
)?;
client.refresh_tags().await?;
client.refresh_custom_fields().await?;Or refresh multiple datasets at once:
use paperless_api::{PaperlessClient, RefreshData};
let mut client = PaperlessClient::new(
"https://paperless.example.com",
"your-api-token",
None,
)?;
client.refresh([RefreshData::Tags, RefreshData::CustomFields]).await?;§Working with tags
After refreshing tags, you can look them up from the local cache:
use paperless_api::PaperlessClient;
let mut client = PaperlessClient::new(
"https://paperless.example.com",
"your-api-token",
None,
)?;
client.refresh_tags().await?;
if let Some(tag) = client.find_tag_by_name("invoice") {
let docs = client.get_documents_by_tags(&[tag.id], true).await?;
println!("found {} documents", docs.len());
}Re-exports§
pub use client::PaperlessClient;pub use client::RefreshData;pub use custom_field::CustomField;pub use custom_field::DocumentCustomField;pub use document::Document;pub use tag::Tag;pub use task::Task;
Modules§
- client
- correspondent
- custom_
field - document
- Types for working with Paperless documents.
- document_
type - tag
- task