Skip to content

Packages  ›  trotsky

trotsky package

This package provides a comprehensive suite of TypeScript classes and utilities designed to facilitate interaction with the AT Protocol (ATProto) and Bluesky's social networking services.

It offers a structured approach to building and executing sequences of operations—referred to as "steps"—that interact with various aspects of the protocol, such as reading user profiles, posts, likes, follows, and more.

By leveraging the schema definitions outlined in the ATProto lexicons,this package ensures type safety and consistency when interfacing with ATProto's decentralized social networking ecosystem.

Remarks

Although all classes and methods are documented and public, the package is intended for use mainly throught the Trotsky class, which serves as the main entry point using a builder pattern to create and execute sequences of steps.

Example

ts
import { AtpAgent } from "@atproto/api"
import { Trotsky } from "trotsky"

async function main() {
 const agent = new AtpAgent({ service: "https://bsky.social" })
 await agent.login({ identifier: 'trotsky.pirhoo.com', password: 'p4ssw0rd' })

 await Trotsky.init(agent)
   .searchPosts({ q: "pizza" })
     .take(3)
     .each()
       .reply({ text: "🍕 Pizza party! 🍕" })
       .wait(1000)
       .run()
}

main()

Classes

Class

Description

StepActor

Represents a step for retrieving and handling an actor's profile using the Bluesky API.

StepActorBlock

Represents a step that performs an actor block operation using the Bluesky API.

StepActorBlocks

Represents a step for retrieving the authenticated user's blocked actors using the Bluesky API. Supports paginated retrieval of blocked accounts.

StepActorFollow

Represents a step that performs an actor follow operation using the agent.

StepActorFollowers

Represents a step for retrieving an actor's followers using the Bluesky API. Supports paginated retrieval of followers.

StepActorFollowings

Represents a step for retrieving an actor's followings using the Bluesky API. Supports paginated retrieval of followings.

StepActorKnownFollowers

Represents a step for retrieving an actor's known followers (mutual connections) using the Bluesky API. Supports paginated retrieval of known followers.

StepActorLikes

Represents a step for retrieving an actor's likes using the Bluesky API. Supports paginated retrieval of likes.

StepActorLists

Represents step for retrieving the lists associated with a specific actor, extending the StepLists functionality.

StepActorMute

Represents a step that performs an actor mute operation using the Bluesky API.

StepActorMutes

Represents a step for retrieving the authenticated user's muted actors using the Bluesky API. Supports paginated retrieval of muted accounts.

StepActorPosts

Represents a step for retrieving an actor's posts using the Bluesky API. Supports paginated retrieval of posts.

StepActors

An abstract class that extends StepBuilderList to handle a list of actor profiles. It defines a collection of steps dealing with actor entries (StepActorsEntry), which can be appended via the each() method.

StepActorsEntry

Represents a single entry step for processing actor information. Extends ActorMixins to provide common actor-related methods.

StepActorStarterPacks

Represents a step for retrieving an actor's starter packs using the Bluesky API. Supports paginated retrieval of starter packs.

StepActorStreamPosts

A specialized step that extends StepStreamPosts to stream an actor's posts. It uses a Jetstream-based event emitter filtered by the actor's DID.

StepActorSuggestions

Represents a step for retrieving suggested actors to follow using the Bluesky API. Supports paginated retrieval of suggestions.

StepActorUnblock

Represents step that unblocks the current actor (if blocked).

StepActorUnfollow

Represents step that unfollows the current actor (if followed).

StepActorUnmute

Represents step that unmutes the current actor (if muted).

StepBuilderListEntry

Represents an individual entry step within a StepBuilderList.

StepBuilderStreamEntry

Represents an individual entry step within a StepBuilderStream.

StepCreatePost

Represents step that creates a new post on Bluesky using the specified record parameters.

StepDeletePost

Represents a step for deleting a specific post.

StepFeed

Represents a step for retrieving posts from a custom feed using the Bluesky API. Supports paginated retrieval of posts.

StepFeedGenerator

Represents a step for retrieving information about a feed generator using the Bluesky API.

StepList

Represents a step for retrieving a list by its URI.

StepListBlock

Represents a step that performs a list block operation using the Bluesky API. Blocking a list prevents content from users on that list from appearing.

StepListFeed

Represents a step for retrieving posts from a list feed using the Bluesky API. Supports paginated retrieval of posts.

StepListMembers

Represents step for retrieving the members of a specific list, extending the StepActors functionality.

StepListMute

Represents a step that performs a list mute operation using the Bluesky API. Muting a list hides content from users on that list without blocking them.

StepListsEntry

Represents an individual entry step within a StepLists list.

StepListUnblock

Represents a step that performs a list unblock operation using the Bluesky API. Unblocking a list allows content from users on that list to appear again.

StepListUnmute

Represents a step that performs a list unmute operation using the Bluesky API. Unmuting a list allows content from users on that list to appear again.

StepNotifications

Represents a step for retrieving user notifications using the Bluesky API. Supports paginated retrieval of notifications.

StepNotificationsUnreadCount

Represents a step for retrieving the unread notification count using the Bluesky API.

StepNotificationsUpdateSeen

Represents a step for marking notifications as seen using the Bluesky API.

StepPost

Represents a step for retrieving a post by its URI. Extends PostMixins for post-related operations.

StepPostAuthor

Represents a step for retrieving the profile of the author of a specific post. Extends StepActor to reuse actor-related logic.

StepPostLike

Represents a step for liking a specific post.

StepPostLikers

Represents a step for retrieving actors who liked a post using the Bluesky API. Supports paginated retrieval of likers.

StepPostQuotes

Represents a step for retrieving quote posts of a post using the Bluesky API. Supports paginated retrieval of quote posts.

StepPostReply

Represents a step for replying to a specific post.

StepPostRepost

Represents a step for reposting a specific post.

StepPostReposters

Represents a step for retrieving actors who reposted a post using the Bluesky API. Supports paginated retrieval of reposters.

StepPosts

Abstract class representing a list of posts to process.

StepPostsEntry

Represents an individual entry step within a StepPosts list. Extends PostMixins to include common post-related operations.

StepPostThread

Represents a step for retrieving a full post thread with replies using the Bluesky API.

StepPostUnlike

Represents a step for unliking a specific post.

StepPostUnrepost

Represents a step for unreposting (removing repost) a specific post.

StepSave

A step that saves the current output to a JSON file at the specified path.

StepSearchActors

Represents a step for searching actors on Bluesky, with support for pagination.

StepSearchPosts

Represents a step for searching posts on Bluesky, with support for pagination.

StepSearchStarterPacks

Represents a step for searching starter packs on Bluesky, with support for pagination.

StepStarterPack

Represents a step for retrieving a starter pack by its URI.

StepStarterPacks

Abstract class representing a list of starter packs to process.

StepStarterPacksEntry

Represents an individual entry step within a StepStarterPacks list. Provides context for each starter pack in the iteration.

StepStreamPosts

Represents a streaming step that processes posts in real-time.

StepSuggestedFeeds

Represents a step for retrieving suggested custom feeds using the Bluesky API. Supports paginated retrieval of feed suggestions.

StepTap

Represents a step that allows interception of the current Step instance for custom processing or side effects.

StepThreadMute

Represents a step that performs a thread mute operation using the Bluesky API. Muting a thread hides notifications for that thread.

StepThreadUnmute

Represents a step that performs a thread unmute operation using the Bluesky API. Unmuting a thread re-enables notifications for that thread.

StepTimeline

Represents a step for retrieving the authenticated user's timeline using the Bluesky API. Supports paginated retrieval of posts from followed accounts.

StepWait

Represents step that introduces a delay before proceeding to the next step.

StepWhen

Represents a conditional step that evaluates a predicate to determine its outcome.

Trotsky

Trotsky orchestrates a sequence of steps that interact with an .

Abstract Classes

Abstract Class

Description

ActorMixins

A mixin class providing reusable actor-related methods to extend step functionality. These methods append specific actor-related steps to the current chain.

ListMixins

A mixin class providing reusable list-related methods to extend step functionality. These methods append specific list-related steps to the current chain.

PostMixins

A mixin class providing reusable post-related methods to extend step functionality. These methods append specific post-related steps to the current chain.

Step

Represents an abstract step in a sequence managed by the Trotsky framework.

StepBuilder

Represents a builder for a sequence of steps. This class is used internally by the Trotsky framework.

StepBuilderList

Abstract class representing a step that processes paginated lists.

StepBuilderStream

Abstract class representing a step for streaming messages using a Jetstream event emitter.

StepLists

Abstract class representing a list of Lists to process.

Interfaces

Interface

Description

StepPostReplyRecordRef

Represents a reference to a post record, including its URI and CID.

StepPostReplyRef

Represents the reply structure, containing references to both the parent and root posts.

Type Aliases

Type Alias

Description

PostReplyParams

Type representing the parameters for a post reply, including text and optional additional metadata.

ResolvablePostReplyParams

Type representing a value that can be resolved into PostReplyParams.

ResolvableStepCreatePostParams

Type representing a StepCreatePostParams type that may be resolved dynamically at runtime.

StepActorBlocksOutput

Type representing the output of the blocked actors retrieved by StepActorBlocks.

StepActorBlocksQueryParams

Type representing the query parameters for retrieving blocked actors.

StepActorBlocksQueryParamsCursor

Type representing the cursor for paginated queries.

StepActorFollowersOutput

Type representing the output of the followers retrieved by StepActorFollowers.

StepActorFollowersQueryParams

Type representing the query parameters for retrieving followers.

StepActorFollowersQueryParamsCursor

Type representing the cursor for paginated queries.

StepActorFollowingsOutput

Type representing the output of the followings retrieved by StepActorFollowings.

StepActorFollowingsQueryParams

Type representing the query parameters for retrieving followings.

StepActorFollowingsQueryParamsCursor

Type representing the cursor for paginated queries.

StepActorKnownFollowersOutput

Type representing the output of the known followers retrieved by StepActorKnownFollowers.

StepActorKnownFollowersQueryParams

Type representing the query parameters for retrieving known followers.

StepActorKnownFollowersQueryParamsCursor

Type representing the cursor for paginated queries.

StepActorLikesOutput

Type representing the output of the likes retrieved by StepActorLikes.

StepActorLikesQueryParams

Type representing the query parameters for retrieving actor likes.

StepActorLikesQueryParamsCursor

Type representing the cursor for paginated queries.

StepActorListsOutput

Type representing the output type for the StepActorLists step, which is an array of lists associated with an actor.

StepActorListsQueryParams

Type representing the query parameters for retrieving an actor's lists.

StepActorListsQueryParamsCursor

Type representing the cursor type for paginated queries when retrieving an actor's lists.

StepActorMutesOutput

Type representing the output of the muted actors retrieved by StepActorMutes.

StepActorMutesQueryParams

Type representing the query parameters for retrieving muted actors.

StepActorMutesQueryParamsCursor

Type representing the cursor for paginated queries.

StepActorOutput

Type for the output of the StepActor class. Matches the schema of the actor profile from the Bluesky API.

StepActorParam

Type for the parameter passed to the StepActor class. Represents the identifier of an actor (e.g., handle or DID).

StepActorPostsOutput

Type representing the output of the posts retrieved by StepActorPosts.

StepActorPostsQueryParams

Type representing the query parameters for retrieving actor posts.

StepActorPostsQueryParamsCursor

Type representing the cursor for paginated queries.

StepActorsOutput

Type representing the output schema for a list of actors' profiles.

StepActorsParam

Type for the parameter passed to the StepActors class. Represents the identifiers of several actors (e.g., handle or DID). Bluesky currently limit this to 25 actors.

StepActorStarterPacksOutput

Type representing the output of the starter packs retrieved by StepActorStarterPacks.

StepActorStarterPacksQueryParams

Type representing the query parameters for retrieving actor starter packs.

StepActorStarterPacksQueryParamsCursor

Type representing the cursor for paginated queries.

StepActorStreamPostsOutput

Combines a Jetstream message commit with a partial post record. Typically represents the streamed output of a single post event.

StepActorSuggestionsOutput

Type representing the output of the suggested actors retrieved by StepActorSuggestions.

StepActorSuggestionsQueryParams

Type representing the query parameters for retrieving suggested actors.

StepActorSuggestionsQueryParamsCursor

Type representing the cursor for paginated queries.

StepBuilderConfig

Represents the configuration object for a StepBuilder instance.

StepBuilderListIterator

Iterator function to be executed for each item in the list.

StepBuilderListOutput

Represents the output of a list step as an array of items.

StepCreatePostOutput

Defines the output of a create-post operation, containing the post's unique URI and CID.

StepCreatePostParams

Defines the parameters for creating a new post. Consists of a partial but excludes createdAt.

StepFeedGeneratorOutput

Type representing the output of the feed generator retrieved by StepFeedGenerator.

StepFeedGeneratorUri

Type representing the URI of a feed generator.

StepFeedOutput

Type representing the output of the feed retrieved by StepFeed.

StepFeedQueryParams

Type representing the query parameters for retrieving a feed.

StepFeedQueryParamsCursor

Type representing the cursor for paginated queries.

StepFeedUri

Type representing the URI of a custom feed.

StepListFeedOutput

Type representing the output of the list feed retrieved by StepListFeed.

StepListFeedQueryParams

Type representing the query parameters for retrieving a list feed.

StepListFeedQueryParamsCursor

Type representing the cursor for paginated queries.

StepListMembersOutput

Represents the output type for the StepListMembers step, which is an array of actor profiles.

StepListMembersQueryParams

Represents the query parameters for retrieving a list's members.

StepListMembersQueryParamsCursor

Represents the cursor type for paginated queries when retrieving list members.

StepListOutput

Represents the output of a retrieved list, including its URI and CID

StepListQueryParams

Defines the query parameters for retrieving a list.

StepListsOutput

Represents the output of a Lists step, consisting of an array of List views.

StepListUri

Represents a list's URI, which can be a string or an .

StepNotificationsOutput

Type representing the output of the notifications retrieved by StepNotifications.

StepNotificationsQueryParams

Type representing the query parameters for retrieving notifications.

StepNotificationsQueryParamsCursor

Type representing the cursor for paginated queries.

StepNotificationsUnreadCountOutput

Type representing the output of the unread count retrieved by StepNotificationsUnreadCount.

StepPostAuthorOutput

Represents the output of the StepPostAuthor, which is equivalent to StepActorOutput.

StepPostLikeOutput

Represents the output of the StepPostLike step, which contains the URI and CID of the liked post.

StepPostLikersOutput

Type representing the output of the likers retrieved by StepPostLikers. Each entry contains the actor who liked the post.

StepPostLikersQueryParams

Type representing the query parameters for retrieving post likers.

StepPostLikersQueryParamsCursor

Type representing the cursor for paginated queries.

StepPostOutput

Represents the output of a retrieved post, including its URI, CID, record data, and author profile.

StepPostQueryParams

Defines the query parameters for retrieving a post.

StepPostQuotesOutput

Type representing the output of the quotes retrieved by StepPostQuotes.

StepPostQuotesQueryParams

Type representing the query parameters for retrieving post quotes.

StepPostQuotesQueryParamsCursor

Type representing the cursor for paginated queries.

StepPostReplyOutput

Represents the output of a post reply step, including the URI and CID of the reply.

StepPostRepostersOutput

Type representing the output of the reposters retrieved by StepPostReposters.

StepPostRepostersQueryParams

Type representing the query parameters for retrieving post reposters.

StepPostRepostersQueryParamsCursor

Type representing the cursor for paginated queries.

StepPostRepostOutput

Represents the output of a repost step, including the URI and CID of the reposted content.

StepPostsOutput

Represents the output of a posts step, consisting of an array of post views.

StepPostsUris

Type for the parameter passed to the StepPosts class. Represents the URIs of several post. Bluesky currently limit this to 25 posts.

StepPostThreadOutput

Type representing the output of the thread retrieved by StepPostThread.

StepPostThreadQueryParams

Type representing the query parameters for retrieving a post thread.

StepPostUri

Represents a post's URI, which can be a string or an .

StepSavePath

Type representing the path of the JSON file to save the output.

StepSearchActorsOutput

Represents the output of a search actors step, consisting of an array of actor profiles.

StepSearchActorsQueryParams

Represents the query parameters for searching actors.

StepSearchActorsQueryParamsCursor

Represents the cursor for paginating through search actor results.

StepSearchPostsOutput

Represents the output of a search posts step, consisting of an array of posts.

StepSearchPostsQueryParams

Represents the query parameters for searching posts.

StepSearchPostsQueryParamsCursor

Represents the cursor for paginating through search post results.

StepSearchStarterPacksOutput

Represents the output of a search starter packs step, consisting of an array of starter packs.

StepSearchStarterPacksQueryParams

Represents the query parameters for searching starter packs.

StepSearchStarterPacksQueryParamsCursor

Represents the cursor for paginating through search starter pack results.

StepStarterPackOutput

Represents the output of a retrieved starter pack, including its URI, CID, record data, creator, and associated lists/feeds.

StepStarterPackQueryParams

Defines the query parameters for retrieving a starter pack.

StepStarterPacksOutput

Represents the output of a starter packs step, consisting of an array of starter pack views.

StepStarterPacksQueryParams

Defines the query parameters for retrieving multiple starter packs.

StepStarterPacksUris

Type for the parameter passed to the StepStarterPacks class. Represents the URIs of several starter packs.

StepStarterPackUri

Represents a starter pack's URI, which can be a string or an .

StepSuggestedFeedsOutput

Type representing the output of the suggested feeds retrieved by StepSuggestedFeeds.

StepSuggestedFeedsQueryParams

Type representing the query parameters for retrieving suggested feeds.

StepSuggestedFeedsQueryParamsCursor

Type representing the cursor for paginated queries.

StepTapInterceptor

Defines the type for a function that intercepts a Step instance. The interceptor can be synchronous or asynchronous.

StepTimelineOutput

Type representing the output of the timeline retrieved by StepTimeline.

StepTimelineQueryParams

Type representing the query parameters for retrieving the timeline.

StepTimelineQueryParamsCursor

Type representing the cursor for paginated queries.

StepWhenPredicate

Boolean values resolved by the StepWhen predicate.