Skip to content

Packages  ›  trotsky  ›  StepFeed

StepFeed class

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

Signature:

typescript
export declare class StepFeed<P = Trotsky, C = null, O extends StepFeedOutput = StepFeedOutput> extends StepPosts<P, C, O>

Extends: StepPosts<P, C, O>

Example 1

Get posts from a custom feed:

ts
await Trotsky.init(agent)
  .feed("at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/whats-hot")
  .take(20)
  .each()
  .tap((step) => {
    console.log(`@${step.context.author.handle}: ${step.context.record.text}`)
  })
  .run()

Example 2

Like posts from a feed with specific criteria:

ts
await Trotsky.init(agent)
  .feed("at://did:plc:example/app.bsky.feed.generator/typescript")
  .take(50)
  .each()
  .when((step) => step?.context?.likeCount > 10)
  .like()
  .wait(1000)
  .run()

Constructors

Constructor

Modifiers

Description

(constructor)(agent, parent, feedUri)

Initializes the StepFeed instance with the given agent, parent, and feed URI.

Properties

Property

Modifiers

Type

Description

_feedUri

StepFeedUri

The URI of the custom feed.

Methods

Method

Modifiers

Description

applyPagination()

Applies pagination to retrieve feed posts and sets the output. Fetches paginated results using the agent and appends them to the output.

clone()

Clones the current step and returns a new instance with the same parameters.

queryParams(cursor)

Generates query parameters for retrieving the feed, including the optional cursor.