Skip to content

Packages  ›  trotsky  ›  StepTimeline

StepTimeline class

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

Signature:

typescript
export declare class StepTimeline<P, C = null, O extends StepTimelineOutput = StepTimelineOutput> extends StepPosts<P, C, O>

Extends: StepPosts<P, C, O>

Example 1

Get recent posts from your timeline:

ts
await Trotsky.init(agent)
  .timeline()
  .take(20)
  .each()
  .tap((step) => {
    console.log(`@${step.context.author.handle}: ${step.context.record.text}`)
  })
  .run()

Example 2

Like posts from your timeline with specific criteria:

ts
await Trotsky.init(agent)
  .timeline()
  .take(50)
  .each()
  .when((step) => step?.context?.record?.text?.includes("#typescript"))
  .like()
  .wait(1000)
  .run()

Example 3

Use a custom algorithm for timeline:

ts
await Trotsky.init(agent)
  .timeline({ algorithm: "reverse-chronological" })
  .take(10)
  .each()
  .run()

Constructors

Constructor

Modifiers

Description

(constructor)(agent, parent, queryParams)

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

Properties

Property

Modifiers

Type

Description

_queryParams

StepTimelineQueryParams

Query parameters for the timeline request.

Methods

Method

Modifiers

Description

applyPagination()

Applies pagination to retrieve timeline 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 timeline, including the optional cursor.