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.

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.

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.

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.

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.

StepActorUnblock

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

StepActorUnfollow

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

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.

StepList

Represents a step for retrieving a list by its URI.

StepListMembers

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

StepListsEntry

Represents an individual entry step within a StepLists list.

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.

StepPostReply

Represents a step for replying to a specific post.

StepPostRepost

Represents a step for reposting a specific post.

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.

StepSave

A step

StepSearchPosts

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

StepStreamPosts

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

StepTap

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

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.

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.

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.

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.

StepActorStreamPostsOutput

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

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.

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 .

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.

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.

StepPostReplyOutput

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

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.

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.

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.

StepTapInterceptor

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

StepWhenPredicate

Boolean values resolved by the StepWhen predicate.