atproto 1.1.0 copy "atproto: ^1.1.0" to clipboard
atproto: ^1.1.0 copied to clipboard

The most famous and powerful Dart/Flutter library for AT Protocol.

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 🏄 #

14
likes
160
points
5.04k
downloads

Publisher

verified publisheratprotodart.com

Weekly Downloads

The most famous and powerful Dart/Flutter library for AT Protocol.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#atproto #bluesky #api

Documentation

Documentation
API reference

Funding

Consider supporting this project:

github.com

License

BSD-3-Clause (license)

Dependencies

atproto_core, freezed_annotation, json_annotation

More

Packages that depend on atproto