class Firehose

extends EventEmitter

Constructor

constructor(relay?, options?)

Creates a new Firehose instance.

Parameters

relay: string = "wss://bsky.network"

The relay to connect to.

options: FirehoseOptions = {}

Optional configuration.

Properties

ws?: WebSocket

WebSocket connection to the relay.

cursor: string

The current cursor.

relay: string

The relay to connect to.

Methods

start()

Opens a WebSocket connection to the relay.

close()

Closes the WebSocket connection.

Overload 1/11

on(event, listener)

Emitted when the connection is opened.

Parameters

event: "open"
listener: () => void

Returns

this

on(event, listener)

Emitted when the connection is closed.

Parameters

event: "close"
listener: (cursor: string) => void

Returns

this

on(event, listener)

Emitted when an error occurs while handling a message.

Parameters

event: "error"
listener: ({ cursor: string; error: Error; }) => void

Returns

this

on(event, listener)

Emitted when an error occurs within the websocket.

Parameters

event: "websocketError"
listener: ({ cursor: string; error: unknown; }) => void

Returns

this

on(event, listener)

Emitted when an unknown message is received.

Parameters

event: "unknown"
listener: (message: unknown) => void

Returns

this

on(event, listener)

Represents an update of an account's handle, or transition to/from invalid state. NOTE: Will be deprecated in favor of #identity.

Parameters

event: "handle"
listener: (message: Handle & { $type: "com.atproto.sync.subscribeRepos#handle"; }) => void

Returns

this

on(event, listener)

Represents an account moving from one PDS instance to another. NOTE: not implemented; account migration uses #identity instead

Parameters

event: "migrate"
listener: (message: Migrate & { $type: "com.atproto.sync.subscribeRepos#migrate"; }) => void

Returns

this

on(event, listener)

Indicates that an account has been deleted. NOTE: may be deprecated in favor of #identity or a future #account event

Parameters

event: "tombstone"
listener: (message: Tombstone & { $type: "com.atproto.sync.subscribeRepos#tombstone"; }) => void

Returns

this

on(event, listener)

Represents a change to an account's identity. Could be an updated handle, signing key, or pds hosting endpoint.

Parameters

event: "identity"
listener: (message: Identity & { $type: "com.atproto.sync.subscribeRepos#identity"; }) => void

Returns

this

on(event, listener)

Represents a commit to a user's repository.

Parameters

event: "commit"
listener: (message: ParsedCommit) => void

Returns

this

on(event, listener)

An informational message from the relay.

Parameters

event: "info"
listener: (message: Info & { $type: "com.atproto.sync.subscribeRepos#info"; }) => void

Returns

this