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
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 |
---|---|
Represents a step for retrieving and handling an actor's profile using the Bluesky API. | |
Represents a step that performs an actor block operation using the Bluesky API. | |
Represents a step that performs an actor follow operation using the agent. | |
Represents a step for retrieving an actor's followers using the Bluesky API. Supports paginated retrieval of followers. | |
Represents a step for retrieving an actor's followings using the Bluesky API. Supports paginated retrieval of followings. | |
Represents a step for retrieving an actor's likes using the Bluesky API. Supports paginated retrieval of likes. | |
Represents step for retrieving the lists associated with a specific actor, extending the StepLists functionality. | |
Represents a step for retrieving an actor's posts using the Bluesky API. Supports paginated retrieval of posts. | |
An abstract class that extends StepBuilderList to handle a list of actor profiles. It defines a collection of steps dealing with actor entries ( | |
Represents a single entry step for processing actor information. Extends ActorMixins to provide common actor-related methods. | |
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. | |
Represents step that unblocks the current actor (if blocked). | |
Represents step that unfollows the current actor (if followed). | |
Represents an individual entry step within a StepBuilderList. | |
Represents an individual entry step within a StepBuilderStream. | |
Represents step that creates a new post on Bluesky using the specified record parameters. | |
Represents a step for retrieving a list by its URI. | |
Represents step for retrieving the members of a specific list, extending the StepActors functionality. | |
Represents an individual entry step within a StepLists list. | |
Represents a step for retrieving a post by its URI. Extends PostMixins for post-related operations. | |
Represents a step for retrieving the profile of the author of a specific post. Extends StepActor to reuse actor-related logic. | |
Represents a step for liking a specific post. | |
Represents a step for replying to a specific post. | |
Represents a step for reposting a specific post. | |
Abstract class representing a list of posts to process. | |
Represents an individual entry step within a StepPosts list. Extends PostMixins to include common post-related operations. | |
A step | |
Represents a step for searching posts on Bluesky, with support for pagination. | |
Represents a streaming step that processes posts in real-time. | |
Represents a step that allows interception of the current Step instance for custom processing or side effects. | |
Represents step that introduces a delay before proceeding to the next step. | |
Represents a conditional step that evaluates a predicate to determine its outcome. | |
Trotsky orchestrates a sequence of steps that interact with an . |
Abstract Classes
Abstract Class | Description |
---|---|
A mixin class providing reusable actor-related methods to extend step functionality. These methods append specific actor-related steps to the current chain. | |
A mixin class providing reusable list-related methods to extend step functionality. These methods append specific list-related steps to the current chain. | |
A mixin class providing reusable post-related methods to extend step functionality. These methods append specific post-related steps to the current chain. | |
Represents an abstract step in a sequence managed by the Trotsky framework. | |
Represents a builder for a sequence of steps. This class is used internally by the Trotsky framework. | |
Abstract class representing a step that processes paginated lists. | |
Abstract class representing a step for streaming messages using a Jetstream event emitter. | |
Abstract class representing a list of Lists to process. |
Interfaces
Interface | Description |
---|---|
Represents a reference to a post record, including its URI and CID. | |
Represents the reply structure, containing references to both the parent and root posts. |
Type Aliases
Type Alias | Description |
---|---|
Type representing the parameters for a post reply, including text and optional additional metadata. | |
Type representing a value that can be resolved into PostReplyParams. | |
Type representing a StepCreatePostParams type that may be resolved dynamically at runtime. | |
Type representing the output of the followers retrieved by StepActorFollowers. | |
Type representing the query parameters for retrieving followers. | |
Type representing the cursor for paginated queries. | |
Type representing the output of the followings retrieved by StepActorFollowings. | |
Type representing the query parameters for retrieving followings. | |
Type representing the cursor for paginated queries. | |
Type representing the output of the likes retrieved by StepActorLikes. | |
Type representing the query parameters for retrieving actor likes. | |
Type representing the cursor for paginated queries. | |
Type representing the output type for the StepActorLists step, which is an array of lists associated with an actor. | |
Type representing the query parameters for retrieving an actor's lists. | |
Type representing the cursor type for paginated queries when retrieving an actor's lists. | |
Type for the output of the StepActor class. Matches the schema of the actor profile from the Bluesky API. | |
Type for the parameter passed to the StepActor class. Represents the identifier of an actor (e.g., handle or DID). | |
Type representing the output of the posts retrieved by StepActorPosts. | |
Type representing the query parameters for retrieving actor posts. | |
Type representing the cursor for paginated queries. | |
Type representing the output schema for a list of actors' profiles. | |
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. | |
Combines a Jetstream message commit with a partial post record. Typically represents the streamed output of a single post event. | |
Represents the configuration object for a StepBuilder instance. | |
Iterator function to be executed for each item in the list. | |
Represents the output of a list step as an array of items. | |
Defines the output of a create-post operation, containing the post's unique URI and CID. | |
Defines the parameters for creating a new post. Consists of a partial but excludes | |
Represents the output type for the StepListMembers step, which is an array of actor profiles. | |
Represents the query parameters for retrieving a list's members. | |
Represents the cursor type for paginated queries when retrieving list members. | |
Represents the output of a retrieved list, including its URI and CID | |
Defines the query parameters for retrieving a list. | |
Represents the output of a Lists step, consisting of an array of List views. | |
Represents a list's URI, which can be a string or an . | |
Represents the output of the | |
Represents the output of the | |
Represents the output of a retrieved post, including its URI, CID, record data, and author profile. | |
Defines the query parameters for retrieving a post. | |
Represents the output of a post reply step, including the URI and CID of the reply. | |
Represents the output of a repost step, including the URI and CID of the reposted content. | |
Represents the output of a posts step, consisting of an array of post views. | |
Type for the parameter passed to the StepPosts class. Represents the URIs of several post. Bluesky currently limit this to 25 posts. | |
Represents a post's URI, which can be a string or an . | |
Type representing the path of the JSON file to save the output. | |
Represents the output of a search posts step, consisting of an array of posts. | |
Represents the query parameters for searching posts. | |
Represents the cursor for paginating through search post results. | |
Defines the type for a function that intercepts a Step instance. The interceptor can be synchronous or asynchronous. | |
Boolean values resolved by the StepWhen predicate. |