atproto

Comprehensive AT Protocol client library for Dart and Flutter

1. Guide 🌎

The atproto package provides a comprehensive, production-ready client library for the AT Protocol. It offers complete coverage of the com.atproto.* namespace, enabling developers to build robust applications that interact with AT Protocol services like Bluesky Social and other decentralized social networks.

This library is designed for developers who need full AT Protocol functionality, including repository management, identity services, moderation tools, and real-time data synchronization. It provides both session-based and OAuth authentication, making it suitable for various application architectures.

Built on top of atproto_core, this package offers high-level abstractions while maintaining access to low-level protocol features. For Bluesky-specific functionality, consider using the complementary bluesky package alongside this one.

1.1. Features ⭐

  • Complete AT Protocol Coverage - Full support for all com.atproto.* endpoints and services
  • Multiple Authentication Methods - Session-based auth, OAuth DPoP, and anonymous access
  • Real-time Data Streaming - Powerful Firehose API for live data synchronization
  • Advanced Retry Logic - Built-in exponential backoff with jitter for reliability
  • Repository Management - Complete CRUD operations for AT Protocol records
  • Identity Services - Handle resolution, DID management, and identity operations
  • Moderation Tools - Report creation and content moderation capabilities
  • Cross-platform Support - Works with Dart, Flutter, and server-side applications
  • Type Safety - 100% null safety with comprehensive type definitions
  • Service Agnostic - Compatible with any AT Protocol service, not just Bluesky

1.2. Getting Started 💪

1.2.1. Install Library

With Dart:

dart pub add atproto

Or With Flutter:

flutter pub add atproto

1.2.2. Import

import 'package:atproto/atproto.dart';

1.2.3. Implementation

Basic Session Authentication

import 'package:atproto/atproto.dart';
import 'package:atproto/core.dart';

Future<void> main() async {
  // Create a session with your credentials
  final session = await createSession(
    service: 'bsky.social', // or your preferred AT Protocol service
    identifier: 'your.handle.bsky.social',
    password: 'your-app-password',
  );

  // Initialize the AT Protocol client
  final atproto = ATProto.fromSession(
    session.data,
    retryConfig: RetryConfig(
      maxAttempts: 3,
      jitter: Jitter(minInSeconds: 1, maxInSeconds: 3),
    ),
  );
}

Repository Operations

// Create a new record
final record = await atproto.repo.createRecord(
  repo: session.data.did,
  collection: 'app.bsky.feed.post',
  record: {
    'text': 'Hello AT Protocol!',
    'createdAt': DateTime.now().toUtc().toIso8601String(),
  },
);

// Get a specific record
final retrievedRecord = await atproto.repo.getRecord(
  repo: session.data.did,
  collection: 'app.bsky.feed.post',
  rkey: 'record-key',
);

// List records in a collection
final records = await atproto.repo.listRecords(
  repo: session.data.did,
  collection: 'app.bsky.feed.post',
  limit: 50,
);

Identity and Handle Management

// Resolve a handle to DID
final didResult = await atproto.identity.resolveHandle(
  handle: 'user.bsky.social',
);

// Update your handle
await atproto.identity.updateHandle(
  handle: 'new-handle.bsky.social',
);

Real-time Data with Firehose

import 'package:atproto/atproto.dart';
import 'package:atproto/com_atproto_sync_subscriberepos.dart';
import 'package:atproto/firehose.dart' as firehose;

Future<void> main() async {
  // Initialize the AT Protocol client
  final atproto = ATProto.anonymous();

  // Subscribe to the repository stream
  final subscription = await atproto.sync.subscribeRepos();

  subscription.data.stream.listen((event) {
    final repos = const firehose.SyncSubscribeReposAdaptor().execute(event);

    repos.whenOrNull(commit: print);
  });
}

1.3. Supported Endpoints 👀

The atproto package provides comprehensive coverage of all AT Protocol services:

Server Service (com.atproto.server.*)

  • Session Management - Create, refresh, and manage user sessions
  • Account Operations - Account creation, deletion, and status management
  • App Passwords - Create and manage application-specific passwords
  • Invite Codes - Generate and manage invitation codes

Identity Service (com.atproto.identity.*)

  • Handle Resolution - Resolve handles to DIDs and vice versa
  • Handle Updates - Update user handles and identity information
  • DID Operations - Manage decentralized identifiers

Repository Service (com.atproto.repo.*)

  • Record CRUD - Create, read, update, and delete records
  • Batch Operations - Apply multiple writes in a single transaction
  • Repository Listing - List records and collections
  • Blob Management - Upload and manage binary data

Sync Service (com.atproto.sync.*)

  • Firehose API - Real-time repository change streams
  • Repository Sync - Synchronize repository states
  • Blob Retrieval - Access repository blobs and data

Moderation Service (com.atproto.moderation.*)

  • Report Creation - Submit moderation reports
  • Content Flagging - Flag inappropriate content

Label Service (com.atproto.label.*)

  • Label Queries - Query content labels and metadata
  • Label Subscriptions - Subscribe to label updates

Complete API Reference

1.4. More Tips 🏄

Libraries

atproto
atproto_oauth
com_atproto_admin_defs
com_atproto_admin_deleteaccount
com_atproto_admin_disableaccountinvites
com_atproto_admin_disableinvitecodes
com_atproto_admin_enableaccountinvites
com_atproto_admin_getaccountinfo
com_atproto_admin_getaccountinfos
com_atproto_admin_getinvitecodes
com_atproto_admin_getsubjectstatus
com_atproto_admin_searchaccounts
com_atproto_admin_sendemail
com_atproto_admin_updateaccountemail
com_atproto_admin_updateaccounthandle
com_atproto_admin_updateaccountpassword
com_atproto_admin_updateaccountsigningkey
com_atproto_admin_updatesubjectstatus
com_atproto_identity_defs
com_atproto_identity_getrecommendeddidcredentials
com_atproto_identity_refreshidentity
com_atproto_identity_resolvedid
com_atproto_identity_resolvehandle
com_atproto_identity_resolveidentity
com_atproto_identity_signplcoperation
com_atproto_identity_submitplcoperation
com_atproto_identity_updatehandle
com_atproto_label_defs
com_atproto_label_querylabels
com_atproto_label_subscribelabels
com_atproto_lexicon_schema
com_atproto_moderation_createreport
com_atproto_moderation_defs
com_atproto_repo_applywrites
com_atproto_repo_createrecord
com_atproto_repo_defs
com_atproto_repo_deleterecord
com_atproto_repo_describerepo
com_atproto_repo_getrecord
com_atproto_repo_listmissingblobs
com_atproto_repo_listrecords
com_atproto_repo_putrecord
com_atproto_repo_strongref
com_atproto_repo_uploadblob
com_atproto_server_checkaccountstatus
com_atproto_server_confirmemail
com_atproto_server_createaccount
com_atproto_server_createapppassword
com_atproto_server_createinvitecode
com_atproto_server_createinvitecodes
com_atproto_server_createsession
com_atproto_server_deactivateaccount
com_atproto_server_defs
com_atproto_server_deleteaccount
com_atproto_server_describeserver
com_atproto_server_getaccountinvitecodes
com_atproto_server_getserviceauth
com_atproto_server_getsession
com_atproto_server_listapppasswords
com_atproto_server_refreshsession
com_atproto_server_requestemailupdate
com_atproto_server_requestpasswordreset
com_atproto_server_reservesigningkey
com_atproto_server_resetpassword
com_atproto_server_revokeapppassword
com_atproto_server_updateemail
com_atproto_services
com_atproto_sync_defs
com_atproto_sync_getblob
com_atproto_sync_getblocks
com_atproto_sync_getcheckout
com_atproto_sync_gethead
com_atproto_sync_gethoststatus
com_atproto_sync_getlatestcommit
com_atproto_sync_getrecord
com_atproto_sync_getrepo
com_atproto_sync_getrepostatus
com_atproto_sync_listblobs
com_atproto_sync_listhosts
com_atproto_sync_listrepos
com_atproto_sync_listreposbycollection
com_atproto_sync_notifyofupdate
com_atproto_sync_requestcrawl
com_atproto_sync_subscriberepos
com_atproto_temp_addreservedhandle
com_atproto_temp_checkhandleavailability
com_atproto_temp_checksignupqueue
com_atproto_temp_fetchlabels
com_atproto_temp_requestphoneverification
com_atproto_temp_revokeaccountcredentials
core
firehose
ids
lex_namespaces