Skip to main content

Crate clickupc_core

Crate clickupc_core 

Source
Expand description

§clickupc-core

crates.io docs.rs License: MIT

Async Rust client for the ClickUp Public API (v2 + v3) — the library behind the clickupc CLI and MCP server.

  • Typed client — tasks, comments, custom fields, tags, links, dependencies, checklists, attachments, time entries, hierarchy, members and Docs.
  • Rate limits handled — tracks X-RateLimit-*, waits for X-RateLimit-Reset on 429 and retries, with a shared limiter for bounded concurrency.
  • Task references — parse ids, custom ids (DEV-123) and task URLs; custom-id query parameters are added for you.
  • Resolver — names → ids for lists ("Space/Folder/List", aliases), spaces, folders, statuses, members (me, username, email), custom fields and options, with a disk cache and “did you mean” suggestions.
  • Human input — parse_when("fri"), parse_duration("1h30m"), custom-field values from option names, dates and numbers.
  • High-level operations — search, create, update (with per-field results), move with status mapping, bulk, batch, standup and list summaries.
  • Tolerant models — ids and timestamps that arrive as strings or numbers, null arrays, unknown fields.
[dependencies]
clickupc-core = "1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

§Search with human input

use clickupc_core::{
    ops::{self, SearchInput},
    ClickUpClient, ClickUpConfig, Resolver,
};

#[tokio::main]
async fn main() -> clickupc_core::Result<()> {
    // Same profile file and CLICKUP_* env vars as the clickupc CLI.
    let cfg = ClickUpConfig::load()?;
    let client = ClickUpClient::new(&cfg)?;
    let resolver = Resolver::new(&client, &cfg)?;

    let tasks = ops::search(
        &resolver,
        &SearchInput {
            lists: vec!["Engineering/Sprints/Sprint 12".into()],
            assignees: vec!["me".into()],
            due_before: Some("eow".into()),
            ..Default::default()
        },
    )
    .await?;

    for t in &tasks {
        println!("{} {} [{}]", t.display_id(), t.name, t.status.status);
    }
    Ok(())
}

§Low-level client

use clickupc_core::{ClickUpClient, ClickUpConfig, TaskRef};

async fn mark_in_review() -> clickupc_core::Result<()> {
    let mut cfg = ClickUpConfig::with_token("pk_...", "https://api.clickup.com/api");
    cfg.workspace_id = Some("9012345678".into());
    let client = ClickUpClient::new(&cfg)?;

    let task: TaskRef = "DEV-123".parse()?; // custom id → custom_task_ids=true&team_id=…
    let t = client.get_task(&task, false, true).await?;
    client.set_status(&task, "in review").await?;
    println!("{}", t.markdown_description.unwrap_or_default());
    Ok(())
}

Errors are a single ClickUpError enum (Auth, NotFound, Api { status, code, .. }, RateLimit { reset_at }, Resolve { suggestions, .. }, …); personal tokens are redacted from every message.

Part of clickup-commands. MIT licensed. Not affiliated with or endorsed by ClickUp.

Re-exports§

pub use client::ClickUpClient;
pub use client::Query;
pub use config::ClickUpConfig;
pub use error::ClickUpError;
pub use error::Result;
pub use resolve::Resolver;
pub use task_ref::TaskRef;

Modules§

bulk
Bounded-concurrency fan-out for bulk operations. Uses the client’s shared limiter permits, so bulk work and other callers share one budget.
client
HTTP plumbing: auth header, retry on 429, error-body parsing. Resource methods live in sibling modules as impl ClickUpClient blocks.
config
Config file (~/.config/clickupc/config.toml) with named profiles and CLICKUP_* env overrides. Priority: env > selected profile > defaults.
error
filter
TaskFilter → query string. Filters hold resolved ids; name resolution happens in the CLI / MCP layer via Resolver.
model
Response models. Tolerant by design: unknown fields are ignored, most fields are optional, and ids / timestamps go through de helpers.
ops
Operations that take human input (names, dates like tomorrow, option names) and turn them into API calls. Shared by the CLI and MCP server so both behave identically.
rate_limit
Tracks X-RateLimit-* headers, waits proactively when the budget is spent, and bounds concurrency for bulk work. Shared via Arc so parallel callers (bulk CLI commands, concurrent MCP tool calls) don’t stampede.
resolve
Names → ids for lists, spaces, folders, statuses, members, fields and task types, with a disk cache (TTL 1h) and refresh-on-miss. Ambiguous names are an error listing the qualified paths, never a silent pick.
task_ref
Parse a task reference: id, custom id (DEV-123), or task URL.
time
Human date input → unix ms, durations, and display helpers. tz is an IANA name (e.g. Asia/Jakarta); None or an unknown name falls back to the system timezone.