6 releases

0.4.0 Feb 2, 2024
0.3.7 Feb 2, 2024
0.3.0 Nov 21, 2022
0.2.0 Nov 21, 2022

#366 in HTTP client


Used in todoistctl

Apache-2.0 AND MIT

37KB
907 lines

Todolist API crate

cargo add libtodoist

Library usage

Check bin/todoistctl, I think that's the best way to see how to use it. In case it's not good enough, here is an example:

use libtodoist::Client;
use libtodoist::api::CreateRequest;
use libtodoist::enums::Priority;

#[tokio::main]
async fn main() {
    let client = libtodoist::Client::new(cfg.token);

    let create_request = CreateRequest{
        content: "fancy task".to_string(),
        description: Some("with fancy description".to_string()),
        project_id: None, // It will be the default one: Inbox
        section_id: None,
        parent_id: None,
        order: None,
        labels: None,
        priority: Some(Priority::Urgent),
        due_string: Some("tomorrow 10pm".to_string()),
        due_date: None,
        due_datetime: None,
        due_lang: None,
        assignee_id: None,
    };

    match client.task().create(opts.into()).await {
        Ok(Some(task)) => { println!("{:#?}", task); },
        Ok(None) => { println!("something went wrong"); },
        Err(err) => { println!("error: {}", err); },
    };
}

Dependencies

~4–15MB
~218K SLoC