Skip to content

Arrow7000/atproto-fsharp

Repository files navigation

FSharp.ATProto

NuGet CI .NET 10 Tests License: MIT

A native F# library for Bluesky and the AT Protocol.
Built from the ground up in F#. No C# wrappers. Functional-first.


Install

dotnet add package FSharp.ATProto.Bluesky

Quick Example

open FSharp.ATProto.Bluesky

taskResult {
    let! agent = Bluesky.login "https://bsky.social" "my-handle.bsky.social" "app-password"
    let! post = Bluesky.post agent "Hello from F#! 🦋"
    let! like = Bluesky.like agent post // PostRef -> LikeRef (the compiler prevents mix-ups)
    let! reply = Bluesky.replyTo agent "Nice thread!" post // thread root resolved automatically
    let! _ = Bluesky.undo agent like // generic undo — works on any ref type
    return reply
}
// : Task<Result<PostRef, XrpcError>> — no exceptions, ever

Design

  • If it compiles, it's correct -- distinct types for every domain concept (PostRef, LikeRef, FollowRef, BlockRef...) mean the compiler catches your mistakes.
  • The library handles protocol complexity -- thread roots, rich text facets, chat proxy headers -- all resolved automatically.
  • Results, not exceptions -- every public function returns Result. No failwith, no try/catch.
  • Rich domain types -- PostRef, Profile, FeedItem, ConvoSummary, Page<'T>, and more. Plus convenience functions for search, bookmarks, muting, notifications, and moderation.
  • Generated from the spec -- 324 Lexicon schemas compiled to F# types + 237 typed XRPC endpoint wrappers.

Getting Started

See the Quickstart to get up and running in 5 minutes.

Features

  • Posts -- create, reply, quote, delete, with automatic rich text detection (guide)
  • Rich text -- mentions, links, and hashtags detected and resolved automatically (guide)
  • Images -- upload and attach with typed ImageMime and alt text (guide)
  • Social graph -- follow, block, like, repost, mute, with typed refs and generic undo (guide)
  • Feeds -- timeline, author feed, actor likes, bookmarks (guide)
  • Profiles -- get, search, typeahead, batch fetch, upsert (guide)
  • Chat / DMs -- conversations, messages, reactions, with automatic proxy headers (guide)
  • Notifications -- fetch, count unread, mark seen (guide)
  • Moderation -- report content, mute threads, mod lists, and a full moderation engine (guide)
  • Identity -- DID resolution, handle verification, PDS discovery (guide)
  • Lists -- create and manage lists and starter packs (guide)
  • Preferences -- saved feeds, muted words, content filtering (guide)
  • Streaming -- real-time events via Jetstream and Firehose (guide)
  • Video -- upload and post video content (guide)
  • Pagination -- lazy IAsyncEnumerable paginators for timeline, followers, notifications (guide)
  • OAuth -- OAuth 2.0 client with DPoP/PKCE, plus authorization server (guide)
  • Server-side -- feed generator framework, XRPC server, service auth
  • Full XRPC access -- all 237 Bluesky endpoints available as typed wrappers (guide)

Documentation

Full docs at arrow7000.github.io/atproto-fsharp.

  • Quickstart -- zero to first post
  • Build a Bot -- end-to-end tutorial
  • Concepts -- AT Protocol terms explained (DID, Handle, AT-URI, PDS, Lexicon)

Building & Testing

Requires .NET 10 SDK.

dotnet build && dotnet test

2,623 tests across 14 projects.

AI Transparency

This project was built with heavy use of AI coding assistants, mostly Claude Opus 4.6.

To ensure correctness the project validates against ground truth at every layer:

  • Syntax parsing -- tested against the official AT Protocol interop test vectors (valid and invalid inputs for DIDs, Handles, NSIDs, TIDs, AT-URIs, and more)
  • CBOR & CID -- tested against the interop data-model fixtures (known JSON -> CBOR -> CID round-trips), plus property-based tests for encoding invariants
  • Lexicon schemas -- all 324 real lexicon files from the official atproto repo are parsed and validated; the code generator is tested against them
  • Rich text -- property-based tests verify byte-range correctness and facet ordering
  • XRPC / Bluesky -- tested via mock HTTP handlers that verify request construction, multi-step orchestration (e.g. thread root resolution), error handling, and domain type mapping (note: the mocks don't validate against real Bluesky API responses -- that contract is covered by the generated types matching the lexicon schemas above)

All told, 2,623 tests across 14 projects, with zero reliance on manual testing or live API calls.

Documentation guides are written as literate F# scripts (.fsx files) -- every code snippet is compiler-checked during the docs build, so examples can never drift out of sync with the library.

License

MIT

About

Idiomatic F# library for the AT Protocol (atproto/Bluesky)

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors