Skip to content

BlueSky API With Rust

Posted on:November 22, 2024

I wrote a small example of how to create a post using the Atrium bksy-sdk. I contributed it as a PR.

use atrium_api::types::string::Datetime;
use bsky_sdk::BskyAgent;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let agent = BskyAgent::builder().build().await?;
    agent.login("...", "...").await?;
    agent
        .create_record(atrium_api::app::bsky::feed::post::RecordData {
            created_at: Datetime::now(),
            embed: None,
            entities: None,
            facets: None,
            labels: None,
            langs: None,
            reply: None,
            tags: None,
            text: "Hello world, from Rust!".to_string(),
        })
        .await?;
    Ok(())
}