A Rust client library for the Beeminder API.
Go to file
2024-12-27 23:06:09 -05:00
examples Use default username 'me' and clean up query params 2024-12-27 23:06:09 -05:00
src Use default username 'me' and clean up query params 2024-12-27 23:06:09 -05:00
.gitignore Add delete datapoint endpoint 2024-12-19 16:46:58 -05:00
Cargo.lock Initial commit 2024-12-14 13:36:05 -05:00
Cargo.toml Initial commit 2024-12-14 13:36:05 -05:00
LICENSE Add license and update readme 2024-12-20 14:12:35 -05:00
README.md Use default username 'me' and clean up query params 2024-12-27 23:06:09 -05:00

beeminder-rs

An incomplete Rust client library for the Beeminder API.

Why use curl if you can just use serde and reqwest to have 200 dependencies?

You'll find that I add endpoints as I need them. Feel free to create an issue if you need a specific endpoint.

Installation

Add to your Cargo.toml:

[dependencies]
beeminder-rs = "0.1.0"

Usage

use beeminder::{BeeminderClient, types::CreateDatapoint};
use time::OffsetDateTime;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = BeeminderClient::new(std::env::var("BEEMINDER_API_KEY")?);

    // username defaults to 'me'; use `with_username` to change it
    // let client = BeeminderClient::new("api-key").with_username("foo");
    
    // Create a datapoint
    let datapoint = CreateDatapoint::new(42.0)
        .with_timestamp(OffsetDateTime::now_utc())
        .with_comment("Meditation session");
        
    client.create_datapoint("meditation", &datapoint).await?;
    
    // Fetch recent datapoints
    let datapoints = client
        .get_datapoints("meditation", Some("timestamp"), Some(10))
        .await?;
        
    Ok(())
}

Requirements

  • Valid Beeminder API key

License

MIT