A library for ATProtocol identities.
README.md

atproto-client#

HTTP client library for AT Protocol services with DPoP authentication support.

Overview#

atproto-client provides HTTP client functionality specifically designed for interacting with AT Protocol endpoints. This library handles both basic HTTP operations and DPoP-authenticated requests required for secure AT Protocol communication.

Binaries#

All CLI tools require the clap feature:

  • atproto-client-auth: Create and refresh authentication sessions with AT Protocol services using identifier and password
  • atproto-client-app-password: Make authenticated XRPC calls using application-specific Bearer tokens and app passwords
  • atproto-client-dpop: Make authenticated XRPC calls using DPoP (Demonstration of Proof-of-Possession) tokens for enhanced security

Usage#

Basic HTTP Operations#

use atproto_client::client;
use reqwest::Client;

let http_client = Client::new();
let response = client::get_json(&http_client, "https://api.example.com/data").await?;

DPoP Authentication#

use atproto_client::client::{DPoPAuth, get_dpop_json};
use atproto_identity::key::identify_key;

let dpop_auth = DPoPAuth {
    dpop_private_key_data: identify_key("did:key:zQ3sh...")?,
    oauth_access_token: "your_access_token".to_string(),
};

let response = get_dpop_json(&http_client, &dpop_auth, "https://pds.example.com/xrpc/...").await?;

Repository Operations#

use atproto_client::com::atproto::repo::{create_record, CreateRecordRequest};

let create_request = CreateRecordRequest {
    repo: "did:plc:user123".to_string(),
    collection: "app.bsky.feed.post".to_string(),
    record: json!({"$type": "app.bsky.feed.post", "text": "Hello!"}),
    // ...
};

let response = create_record(&http_client, &dpop_auth, pds_url, create_request).await?;

Command Line Examples#

Create and Manage Sessions#

# Create an authentication session with username and password
cargo run --features clap --bin atproto-client-auth -- login alice.example.com my_password

# Use an existing app password for session creation
cargo run --features clap --bin atproto-client-auth -- session alice.example.com app_password_token

App Password Authentication#

# Make an XRPC call using app password Bearer token
cargo run --features clap --bin atproto-client-app-password -- \
  did:plc:user123 \
  your_access_token \
  com.atproto.repo.listRecords

DPoP Authentication#

# Make an authenticated XRPC call using DPoP tokens
cargo run --features clap --bin atproto-client-dpop -- \
  did:plc:user123 \
  did:key:zQ3sh... \
  your_access_token \
  com.atproto.repo.getRecord

License#

MIT License