Skip to content

Packages  ›  trotsky  ›  StepSearchPosts

StepSearchPosts class ​

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

Signature:

typescript
export declare class StepSearchPosts<P, C = null, O extends StepSearchPostsOutput = StepSearchPostsOutput> extends StepPosts<P, C, O>

Extends: StepPosts<P, C, O>

Example 1 ​

Search for posts and display them:

ts
await Trotsky.init(agent)
  .searchPosts({ q: "typescript" })
  .take(10)
  .each()
  .tap((step) => {
    console.log(step.context.record.text)
    console.log(`Likes: ${step.context.likeCount}`)
  })
  .run()

Example 2 ​

Like posts matching specific criteria:

ts
await Trotsky.init(agent)
  .searchPosts({ q: "bluesky" })
  .take(20)
  .each()
  .when((step) => step?.context?.likeCount > 5)
  .like()
  .wait(2000)
  .run()

Constructors ​

Constructor

Modifiers

Description

(constructor)(agent, parent, queryParams)

Initializes the StepSearchPosts instance with the given agent, parent, and query parameters.

Properties ​

Property

Modifiers

Type

Description

_queryParams

StepSearchPostsQueryParams

The initial query parameters for the search.

Methods ​

Method

Modifiers

Description

applyPagination()

Applies the pagination logic to retrieve posts based on the search parameters. Results are stored in the output property.

clone(rest)

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

queryParams(cursor)

Constructs the query parameters for the current pagination step.