Files
simplex-chat/packages/simplex-chat-nodejs/docs/api.Class.ChatApi.md
T
Evgeny @ SimpleX Chat 99b91696f7 bots, nodejs: document chat, connection, member contact and network commands, typed commands in library (#7808)
* bots, nodejs: document chat, connection, member contact and network commands, typed commands in library

* bots, nodejs: restore apiConnect, wrap domain once, test all connect responses

* nodejs: JSDoc for new methods

* docs: plan for bot API commands and typed Node library methods

* tests: channel prepared with a domain has a verified SimpleX name

* docs: apply review fixes to the plan for bot API commands

* docs: apply second review pass to the plan for bot API commands

* docs: refer the bot API plan to the rewritten test commit

* docs: record decisions in the plan for bot API commands

* docs: plan tests of the generated Python command strings

* python: test the generated strings of the documented commands

* docs: plan the message information command for bots

* bots, nodejs: message information with the file servers for bots

* docs: plan the relay approval option of receiving files in Node

* nodejs: receive files without approving unknown relays

* docs: plan the user servers command for bots

* bots, nodejs: user servers and relays by operator for bots

* nodejs: document the message information method

* docs: plan the file upload progress event for bots

* bots: file upload progress event for bots

* bots: drop the file upload progress event

* docs: drop the upload progress event plan

* nodejs: document user servers and relay approval of received files
2026-10-31 22:30:16 +00:00

30 KiB

simplex-chat


simplex-chat / api / ChatApi

Class: ChatApi

Defined in: src/api.ts:103

Main API class for interacting with the chat core library.

Properties

ctrl_

protected ctrl_: bigint | undefined

Defined in: src/api.ts:109

Accessors

ctrl

Get Signature

get ctrl(): bigint

Defined in: src/api.ts:348

Chat controller reference

Returns

bigint


initialized

Get Signature

get initialized(): boolean

Defined in: src/api.ts:334

Chat controller is initialized

Returns

boolean


started

Get Signature

get started(): boolean

Defined in: src/api.ts:341

Chat controller is started

Returns

boolean

Methods

apiAcceptContactRequest()

apiAcceptContactRequest(contactReqId): Promise<Contact>

Defined in: src/api.ts:850

Accept contact request. Network usage: interactive.

Parameters

contactReqId

number

Returns

Promise<Contact>


apiAcceptMember()

apiAcceptMember(groupId, groupMemberId, memberRole): Promise<GroupMember>

Defined in: src/api.ts:598

Accept group member. Requires Admin role. Network usage: background.

Parameters

groupId

number

groupMemberId

number

memberRole

GroupMemberRole

Returns

Promise<GroupMember>


apiAddMember()

apiAddMember(groupId, contactId, memberRole): Promise<GroupMember>

Defined in: src/api.ts:568

Add contact to group. Requires bot to have Admin role. Network usage: interactive.

Parameters

groupId

number

contactId

number

memberRole

GroupMemberRole

Returns

Promise<GroupMember>


apiAddMemberViaGroup()

apiAddMemberViaGroup(groupId, viaGroupId, groupMemberId, memberRole): Promise<GroupMember>

Defined in: src/api.ts:578

Add member of another group to group. Requires bot to have Admin role in the group, and direct messages allowed for its role in another group. Network usage: interactive.

Parameters

groupId

number

viaGroupId

number

groupMemberId

number

memberRole

GroupMemberRole

Returns

Promise<GroupMember>


apiBlockMembersForAll()

apiBlockMembersForAll(groupId, groupMemberIds, blocked): Promise<void>

Defined in: src/api.ts:618

Block members. Requires Moderator role. Network usage: background.

Parameters

groupId

number

groupMemberIds

number[]

blocked

boolean

Returns

Promise<void>


apiCancelFile()

apiCancelFile(fileId): Promise<void>

Defined in: src/api.ts:558

Cancel file. Network usage: background.

Parameters

fileId

number

Returns

Promise<void>


apiChatItemReaction()

apiChatItemReaction(chatType, chatId, chatItemId, add, reaction): Promise<ACIReaction>

Defined in: src/api.ts:530

Add/remove message reaction. Network usage: background.

Parameters

chatType

ChatType

chatId

number

chatItemId

number

add

boolean

reaction

MsgReaction

Returns

Promise<ACIReaction>


apiChatItemsRead()

apiChatItemsRead(chatType, chatId, chatItemIds): Promise<ChatInfo>

Defined in: src/api.ts:967

Mark messages as read. Network usage: no.

Parameters

chatType

ChatType

chatId

number

chatItemIds

number[]

Returns

Promise<ChatInfo>


apiConnect()

apiConnect(userId, incognito, preparedLink): Promise<ConnReqType>

Defined in: src/api.ts:747

Connect via prepared SimpleX link. The link can be 1-time invitation link, contact address or group link Network usage: interactive.

Parameters

userId

number

incognito

boolean

CreatedConnLink

Returns

Promise<ConnReqType>


apiConnectActiveUser()

apiConnectActiveUser(connLink): Promise<ConnReqType>

Defined in: src/api.ts:828

Connect via SimpleX link as string in the active user profile. Network usage: interactive.

Parameters

string

Returns

Promise<ConnReqType>


apiConnectContactViaAddress()

apiConnectContactViaAddress(userId, incognito, contactId): Promise<SentInvitationToContact>

Defined in: src/api.ts:818

Connect to existing contact via address in its profile. Network usage: interactive.

Parameters

userId

number

incognito

boolean

contactId

number

Returns

Promise<SentInvitationToContact>


apiConnectPlan()

apiConnectPlan(userId, connectionLink): Promise<[plan: ConnectionPlan, link: CreatedConnLink, planSimplexName?: SimplexNameInfo, otherSimplexName?: SimplexNameInfo]>

Defined in: src/api.ts:737

Determine SimpleX link type and if the bot is already connected via this link. Network usage: interactive.

Parameters

userId

number

string

Returns

Promise<[plan: ConnectionPlan, link: CreatedConnLink, planSimplexName?: SimplexNameInfo, otherSimplexName?: SimplexNameInfo]>


apiConnectPreparedContact()

apiConnectPreparedContact(contactId, incognito, msgContent?): Promise<ContactAlreadyExists | StartedConnectionToContact>

Defined in: src/api.ts:793

Connect to prepared contact. Network usage: interactive.

Parameters

contactId

number

incognito

boolean

msgContent?

MsgContent

Returns

Promise<ContactAlreadyExists | StartedConnectionToContact>


apiConnectPreparedGroup()

apiConnectPreparedGroup(groupId, incognito, msgContent?, ownerContact?): Promise<StartedConnectionToGroup>

Defined in: src/api.ts:808

Connect to prepared group. Network usage: interactive.

Parameters

groupId

number

incognito

boolean

msgContent?

MsgContent

ownerContact?

GroupOwnerContact

Returns

Promise<StartedConnectionToGroup>


apiConnectPreparedLink(userId, incognito, preparedLink): Promise<ContactAlreadyExists | SentConfirmation | SentInvitation>

Defined in: src/api.ts:757

Connect via prepared SimpleX link. The link can be 1-time invitation link, contact address or group link. Returns the response with the pending connection, or with the contact when it already exists. Network usage: interactive.

Parameters

userId

number

incognito

boolean

CreatedConnLink

Returns

Promise<ContactAlreadyExists | SentConfirmation | SentInvitation>


apiContactInfo()

apiContactInfo(contactId): Promise<ContactInfo>

Defined in: src/api.ts:987

Get contact information. Network usage: no.

Parameters

contactId

number

Returns

Promise<ContactInfo>


apiCreateActiveUser()

apiCreateActiveUser(profile?): Promise<User>

Defined in: src/api.ts:1047

Create new user profile Network usage: no.

Parameters

profile?

Profile

Returns

Promise<User>


apiCreateGroupLink(groupId, memberRole): Promise<string>

Defined in: src/api.ts:678

Create group link. Network usage: interactive.

Parameters

groupId

number

memberRole

GroupMemberRole

Returns

Promise<string>


apiCreateLink(userId): Promise<string>

Defined in: src/api.ts:724

Create 1-time invitation link. Network usage: interactive.

Parameters

userId

number

Returns

Promise<string>


apiCreateMemberContact()

apiCreateMemberContact(groupId, groupMemberId): Promise<Contact>

Defined in: src/api.ts:1113

Create a direct message contact with a group member. Returns the created contact. Network usage: interactive.

Parameters

groupId

number

groupMemberId

number

Returns

Promise<Contact>


apiCreateUserAddress()

apiCreateUserAddress(userId): Promise<CreatedConnLink>

Defined in: src/api.ts:365

Create bot address. Network usage: interactive.

Parameters

userId

number

Returns

Promise<CreatedConnLink>


apiDeleteChat()

apiDeleteChat(chatType, chatId, deleteMode?): Promise<void>

Defined in: src/api.ts:909

Delete chat. Network usage: background.

Parameters

chatType

ChatType

chatId

number

deleteMode?

ChatDeleteMode = ...

Returns

Promise<void>


apiDeleteChatItems()

apiDeleteChatItems(chatType, chatId, chatItemIds, deleteMode): Promise<ChatItemDeletion[]>

Defined in: src/api.ts:505

Delete message. Network usage: background.

Parameters

chatType

ChatType

chatId

number

chatItemIds

number[]

deleteMode

CIDeleteMode

Returns

Promise<ChatItemDeletion[]>


apiDeleteGroupLink(groupId): Promise<void>

Defined in: src/api.ts:700

Delete group link. Network usage: background.

Parameters

groupId

number

Returns

Promise<void>


apiDeleteMemberChatItem()

apiDeleteMemberChatItem(groupId, chatItemIds): Promise<ChatItemDeletion[]>

Defined in: src/api.ts:520

Moderate message. Requires Moderator role (and higher than message author's). Network usage: background.

Parameters

groupId

number

chatItemIds

number[]

Returns

Promise<ChatItemDeletion[]>


apiDeleteUser()

apiDeleteUser(userId, delSMPQueues, viewPwd?): Promise<void>

Defined in: src/api.ts:1077

Delete user profile. Network usage: background.

Parameters

userId

number

delSMPQueues

boolean

viewPwd?

string

Returns

Promise<void>


apiDeleteUserAddress()

apiDeleteUserAddress(userId): Promise<void>

Defined in: src/api.ts:375

Deletes a user address. Network usage: background.

Parameters

userId

number

Returns

Promise<void>


apiGetActiveUser()

apiGetActiveUser(): Promise<User | undefined>

Defined in: src/api.ts:1027

Get active user profile Network usage: no.

Returns

Promise<User | undefined>


apiGetChat()

apiGetChat(chatType, chatId, pagination): Promise<AChat>

Defined in: src/api.ts:956

Get chat items. Network usage: no.

Parameters

chatType

ChatType

chatId

number

pagination

number | ChatPagination

Returns

Promise<AChat>


apiGetChatItemInfo()

apiGetChatItemInfo(chatType, chatId, chatItemId): Promise<ChatItemInfo>

Defined in: src/api.ts:977

Get message information. Network usage: no.

Parameters

chatType

ChatType

chatId

number

chatItemId

number

Returns

Promise<ChatItemInfo>


apiGetChats()

apiGetChats(userId, pagination, query?, pendingConnections?): Promise<AChat[]>

Defined in: src/api.ts:894

Get chat previews (paginated). Network usage: no.

Prefer this over apiListContacts / apiListGroups for any scan: those methods load every record into memory in a single response and will fail on large databases.

Parameters

userId

number

pagination

Last

query?

ChatListQuery = ...

pendingConnections?

boolean = false

Returns

Promise<AChat[]>


apiGetGroupLink(groupId): Promise<GroupLink>

Defined in: src/api.ts:709

Get group link. Network usage: no.

Parameters

groupId

number

Returns

Promise<GroupLink>


apiGetGroupLinkStr()

apiGetGroupLinkStr(groupId): Promise<string>

Defined in: src/api.ts:715

Parameters

groupId

number

Returns

Promise<string>


apiGetNetworkConfig()

apiGetNetworkConfig(): Promise<NetworkConfig>

Defined in: src/api.ts:997

Get network configuration. Network usage: no.

Returns

Promise<NetworkConfig>


apiGetUserAddress()

apiGetUserAddress(userId): Promise<UserContactLink | undefined>

Defined in: src/api.ts:385

Get bot address and settings. Network usage: no.

Parameters

userId

number

Returns

Promise<UserContactLink | undefined>


apiGetUserServers()

apiGetUserServers(userId): Promise<UserOperatorServers[]>

Defined in: src/api.ts:1017

Get user servers and chat relays, grouped by operator. Network usage: no.

Parameters

userId

number

Returns

Promise<UserOperatorServers[]>


apiJoinGroup()

apiJoinGroup(groupId): Promise<GroupInfo>

Defined in: src/api.ts:588

Join group. Network usage: interactive.

Parameters

groupId

number

Returns

Promise<GroupInfo>


apiLeaveGroup()

apiLeaveGroup(groupId): Promise<GroupInfo>

Defined in: src/api.ts:638

Leave group. Network usage: background.

Parameters

groupId

number

Returns

Promise<GroupInfo>


apiListContacts()

apiListContacts(userId): Promise<Contact[]>

Defined in: src/api.ts:870

Get contacts. Network usage: no.

Parameters

userId

number

Returns

Promise<Contact[]>


apiListGroups()

apiListGroups(userId, contactId?, search?): Promise<GroupInfo[]>

Defined in: src/api.ts:880

Get groups. Network usage: no.

Parameters

userId

number

contactId?

number

string

Returns

Promise<GroupInfo[]>


apiListMembers()

apiListMembers(groupId): Promise<GroupMember[]>

Defined in: src/api.ts:648

Get group members. Network usage: no.

Parameters

groupId

number

Returns

Promise<GroupMember[]>


apiListUsers()

apiListUsers(): Promise<UserInfo[]>

Defined in: src/api.ts:1057

Get all user profiles Network usage: no.

Returns

Promise<UserInfo[]>


apiNewGroup()

apiNewGroup(userId, groupProfile): Promise<GroupInfo>

Defined in: src/api.ts:658

Create group. Network usage: no.

Parameters

userId

number

groupProfile

GroupProfile

Returns

Promise<GroupInfo>


apiPrepareContact()

apiPrepareContact(userId, connLink, contactSLinkData, verifiedDomain?): Promise<AChat>

Defined in: src/api.ts:773

Prepare contact chat from link data before connecting. Network usage: no.

Parameters

userId

number

CreatedConnLink

contactSLinkData

ContactShortLinkData

verifiedDomain?

string

Returns

Promise<AChat>


apiPrepareGroup()

apiPrepareGroup(userId, connLinkContact, direct, groupSLinkData, verifiedDomain?): Promise<AChat>

Defined in: src/api.ts:783

Prepare group chat from link data before connecting. Network usage: no.

Parameters

userId

number

connLinkContact

CreatedConnLink

direct

boolean

groupSLinkData

GroupShortLinkData

verifiedDomain?

string

Returns

Promise<AChat>


apiReceiveFile()

apiReceiveFile(fileId, filePath?, approvedRelays?): Promise<AChatItem>

Defined in: src/api.ts:547

Receive file. With approvedRelays = false, a file on unknown XFTP relays is received only when the IP address is protected; otherwise fileNotApproved is thrown. Network usage: no.

Parameters

fileId

number

filePath?

string

approvedRelays?

boolean = true

Returns

Promise<AChatItem>


apiRejectContactRequest()

apiRejectContactRequest(contactReqId): Promise<void>

Defined in: src/api.ts:860

Reject contact request. The user who sent the request is not notified. Network usage: no.

Parameters

contactReqId

number

Returns

Promise<void>


apiRemoveMembers()

apiRemoveMembers(groupId, memberIds, withMessages?): Promise<GroupMember[]>

Defined in: src/api.ts:628

Remove members. Requires Admin role. Network usage: background.

Parameters

groupId

number

memberIds

number[]

withMessages?

boolean = false

Returns

Promise<GroupMember[]>


apiSendMemberContactInvitation()

apiSendMemberContactInvitation(contactId, message?): Promise<Contact>

Defined in: src/api.ts:1124

Send a direct message invitation to a group member contact. The contact must have been created with apiCreateMemberContact. Network usage: background.

Parameters

contactId

number

message?

string | MsgContent

Returns

Promise<Contact>


apiSendMessages()

apiSendMessages(chat, messages, liveMessage?): Promise<AChatItem[]>

Defined in: src/api.ts:448

Send messages. Network usage: background.

Parameters

chat

ChatInfo | ChatRef | [ChatType, number]

messages

ComposedMessage[]

liveMessage?

boolean = false

Returns

Promise<AChatItem[]>


apiSendTextMessage()

apiSendTextMessage(chat, text, inReplyTo?): Promise<AChatItem[]>

Defined in: src/api.ts:471

Send text message. Network usage: background.

Parameters

chat

ChatInfo | ChatRef | [ChatType, number]

text

string

inReplyTo?

number

Returns

Promise<AChatItem[]>


apiSendTextReply()

apiSendTextReply(chatItem, text): Promise<AChatItem[]>

Defined in: src/api.ts:479

Send text message in reply to received message. Network usage: background.

Parameters

chatItem

AChatItem

text

string

Returns

Promise<AChatItem[]>


apiSetActiveUser()

apiSetActiveUser(userId, viewPwd?): Promise<User>

Defined in: src/api.ts:1067

Set active user profile Network usage: no.

Parameters

userId

number

viewPwd?

string

Returns

Promise<User>


apiSetAddressSettings()

apiSetAddressSettings(userId, __namedParameters): Promise<void>

Defined in: src/api.ts:419

Set bot address settings. Network usage: interactive.

Parameters

userId

number

__namedParameters

BotAddressSettings

Returns

Promise<void>


apiSetAutoAcceptMemberContacts()

apiSetAutoAcceptMemberContacts(userId, onOff): Promise<void>

Defined in: src/api.ts:946

Set auto-accept member contacts. Network usage: no.

Parameters

userId

number

onOff

boolean

Returns

Promise<void>


apiSetContactCustomData()

apiSetContactCustomData(contactId, customData?): Promise<void>

Defined in: src/api.ts:936

Set contact custom data. Network usage: no.

Parameters

contactId

number

customData?

object

Returns

Promise<void>


apiSetContactPrefs()

apiSetContactPrefs(contactId, preferences): Promise<void>

Defined in: src/api.ts:1103

Configure chat preference overrides for the contact. Network usage: background.

Parameters

contactId

number

preferences

Preferences

Returns

Promise<void>


apiSetGroupCustomData()

apiSetGroupCustomData(groupId, customData?): Promise<void>

Defined in: src/api.ts:926

Set group custom data. Network usage: no.

Parameters

groupId

number

customData?

object

Returns

Promise<void>


apiSetGroupLinkMemberRole()

apiSetGroupLinkMemberRole(groupId, memberRole): Promise<void>

Defined in: src/api.ts:691

Set member role for group link. Network usage: no.

Parameters

groupId

number

memberRole

GroupMemberRole

Returns

Promise<void>


apiSetMembersRole()

apiSetMembersRole(groupId, groupMemberIds, memberRole): Promise<void>

Defined in: src/api.ts:608

Set members role. Requires Admin role. Network usage: background.

Parameters

groupId

number

groupMemberIds

number[]

memberRole

GroupMemberRole

Returns

Promise<void>


apiSetNetworkConfig()

apiSetNetworkConfig(networkConfig): Promise<void>

Defined in: src/api.ts:1007

Set network configuration. Network usage: background.

Parameters

networkConfig

NetworkConfig

Returns

Promise<void>


apiSetProfileAddress()

apiSetProfileAddress(userId, enable): Promise<UserProfileUpdateSummary>

Defined in: src/api.ts:403

Add address to bot profile. Network usage: interactive.

Parameters

userId

number

enable

boolean

Returns

Promise<UserProfileUpdateSummary>


apiSetUserDomain()

apiSetUserDomain(userId, simplexDomain?): Promise<User>

Defined in: src/api.ts:433

Parameters

userId

number

simplexDomain?

string

Returns

Promise<User>


apiUpdateChatItem()

apiUpdateChatItem(chatType, chatId, chatItemId, msgContent, liveMessage?): Promise<ChatItem>

Defined in: src/api.ts:488

Update message. A live message stays live with liveMessage = true and is finalized with liveMessage = false. Network usage: background.

Parameters

chatType

ChatType

chatId

number

chatItemId

number

msgContent

MsgContent

liveMessage?

boolean = false

Returns

Promise<ChatItem>


apiUpdateGroupProfile()

apiUpdateGroupProfile(groupId, groupProfile): Promise<GroupInfo>

Defined in: src/api.ts:668

Update group profile. Network usage: background.

Parameters

groupId

number

groupProfile

GroupProfile

Returns

Promise<GroupInfo>


apiUpdateProfile()

apiUpdateProfile(userId, profile): Promise<UserProfileUpdateSummary | undefined>

Defined in: src/api.ts:1087

Update user profile. Network usage: background.

Parameters

userId

number

profile

Profile

Returns

Promise<UserProfileUpdateSummary | undefined>


close()

close(): Promise<void>

Defined in: src/api.ts:165

Stop chat controller and close chat database. The database is not closed if stopping fails. Usually doesn't need to be called in chat bots.

Returns

Promise<void>


off()

off<K>(event, subscriber?): void

Defined in: src/api.ts:306

Unsubscribe all or a specific handler from a specific event.

Type Parameters

K

K extends Tag

Parameters

event

K

The event type to unsubscribe from.

subscriber?

EventSubscriberFunc<K> | undefined = undefined

An optional subscriber function for the event.

Returns

void


offAny()

offAny(receiver?): void

Defined in: src/api.ts:322

Unsubscribe all or a specific handler from any events.

Parameters

receiver?

EventSubscriberFunc<Tag> | undefined = undefined

An optional subscriber function for the event.

Returns

void


on()

Call Signature

on<K>(subscribers): void

Defined in: src/api.ts:214

Subscribe multiple event handlers at once.

Type Parameters
K

K extends Tag

Parameters
subscribers

EventSubscribers

An object mapping event types (CEvt.Tag) to their subscriber functions.

Returns

void

Throws

If the same function is subscribed to event.

Call Signature

on<K>(event, subscriber): void

Defined in: src/api.ts:222

Subscribe a handler to a specific event.

Type Parameters
K

K extends Tag

Parameters
event

K

The event type to subscribe to.

subscriber

EventSubscriberFunc<K>

The subscriber function for the event.

Returns

void

Throws

If the same function is subscribed to event.


onAny()

onAny(receiver): void

Defined in: src/api.ts:245

Subscribe a handler to any event.

Parameters

receiver

EventSubscriberFunc<Tag>

The receiver function for any event.

Returns

void

Throws

If the same function is subscribed to event.


once()

once<K>(event, subscriber): void

Defined in: src/api.ts:256

Subscribe a handler to a specific event to be delivered one time.

Type Parameters

K

K extends Tag

Parameters

event

K

The event type to subscribe to.

subscriber

EventSubscriberFunc<K>

The subscriber function for the event.

Returns

void

Throws

If the same function is subscribed to event.


recvChatEvent()

recvChatEvent(wait?): Promise<ChatEvent | undefined>

Defined in: src/api.ts:357

Parameters

wait?

number = 500_000

Returns

Promise<ChatEvent | undefined>


sendChatCmd()

sendChatCmd(cmd): Promise<ChatResponse>

Defined in: src/api.ts:353

Parameters

cmd

string

Returns

Promise<ChatResponse>


startChat()

startChat(): Promise<void>

Defined in: src/api.ts:131

Start chat controller. Must be called with the existing user profile.

Returns

Promise<void>


stopChat()

stopChat(): Promise<void>

Defined in: src/api.ts:154

Stop chat controller. close calls it before closing the database. Usually doesn't need to be called in chat bots.

Returns

Promise<void>


wait()

Call Signature

wait<K>(event): Promise<ChatEvent & object>

Defined in: src/api.ts:264

Waits for specific event, with an optional predicate. Returns undefined on timeout if specified.

Type Parameters
K

K extends Tag

Parameters
event

K

Returns

Promise<ChatEvent & object>

Call Signature

wait<K>(event, predicate): Promise<ChatEvent & object>

Defined in: src/api.ts:265

Waits for specific event, with an optional predicate. Returns undefined on timeout if specified.

Type Parameters
K

K extends Tag

Parameters
event

K

predicate

((event) => boolean) | undefined

Returns

Promise<ChatEvent & object>

Call Signature

wait<K>(event, timeout): Promise<ChatEvent & { type: K; } | undefined>

Defined in: src/api.ts:266

Waits for specific event, with an optional predicate. Returns undefined on timeout if specified.

Type Parameters
K

K extends Tag

Parameters
event

K

timeout

number

Returns

Promise<ChatEvent & { type: K; } | undefined>

Call Signature

wait<K>(event, predicate, timeout): Promise<ChatEvent & { type: K; } | undefined>

Defined in: src/api.ts:267

Waits for specific event, with an optional predicate. Returns undefined on timeout if specified.

Type Parameters
K

K extends Tag

Parameters
event

K

predicate

((event) => boolean) | undefined

timeout

number

Returns

Promise<ChatEvent & { type: K; } | undefined>


init()

static init(db, confirm?, queueSize?): Promise<ChatApi>

Defined in: src/api.ts:117

Initializes the ChatApi, loading libsimplex for db.type (downloaded on first use).

Parameters

db

DbConfig

Database configuration (sqlite or postgres).

confirm?

MigrationConfirmation = core.MigrationConfirmation.YesUp

Migration confirmation mode.

queueSize?

number

Size of internal queues, the core default is used when omitted.

Returns

Promise<ChatApi>