61 releases

0.25.2 Apr 2, 2025
0.25.0 Feb 17, 2025
0.24.9 Dec 10, 2024
0.24.8 Nov 19, 2024
0.4.0 Jun 30, 2023

#24 in HTTP client

Download history 90/week @ 2024-12-24 181/week @ 2024-12-31 442/week @ 2025-01-07 377/week @ 2025-01-14 499/week @ 2025-01-21 390/week @ 2025-01-28 492/week @ 2025-02-04 565/week @ 2025-02-11 475/week @ 2025-02-18 515/week @ 2025-02-25 473/week @ 2025-03-04 1123/week @ 2025-03-11 972/week @ 2025-03-18 558/week @ 2025-03-25 963/week @ 2025-04-01 600/week @ 2025-04-08

3,226 downloads per month
Used in 18 crates (12 directly)

MIT license

1MB
20K SLoC

ATrium API: Rust library for Bluesky's atproto services

Rust

ATrium API is a Rust library that includes the definitions of XRPC requests and their associated input/output model types. These codes are generated from the Lexicon schema on atproto.com.

Usage

Any HTTP client that implements atrium_xrpc::HttpClient can be used to handle XRPC requests. Since atrium_xrpc_client provides several implementations, it is recommended to use one of them that fits your project requirements.

use atrium_api::client::AtpServiceClient;
use atrium_xrpc_client::reqwest::ReqwestClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = AtpServiceClient::new(ReqwestClient::new("https://bsky.social"));
    let result = client
        .service
        .com
        .atproto
        .server
        .create_session(
            atrium_api::com::atproto::server::create_session::InputData {
                auth_factor_token: None,
                identifier: "alice@mail.com".into(),
                password: "hunter2".into(),
                allow_takendown: None,
            }
            .into(),
        )
        .await;
    println!("{:?}", result);
    Ok(())
}

AtpAgent (agent feature)

While AtpServiceClient can be used for simple XRPC calls, it is better to use AtpAgent, which has practical features such as session management.

use atrium_api::agent::atp_agent::{store::MemorySessionStore, AtpAgent};
use atrium_xrpc_client::reqwest::ReqwestClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let agent = AtpAgent::new(
        ReqwestClient::new("https://bsky.social"),
        MemorySessionStore::default(),
    );
    agent.login("alice@mail.com", "hunter2").await?;
    let result = agent
        .api
        .com
        .atproto
        .server
        .get_session()
        .await?;
    println!("{:?}", result);
    Ok(())
}

Features

The AtpAgent used in the above example is included in the agent feature. atrium-api enables the agent and bluesky features by default. It is possible to opt-out if not needed.

  • agent: enable the agent module.
  • bluesky: enable bluesky-specific lexicon definitions and XRPC methods.
    • It is also possible to enable only the namespace specified by namespace-*.

Dependencies

~9–35MB
~503K SLoC