Method

setImToken(token: string)

Update the token for an instance

myIm.setImToken('new token')

setImApiKey(apiKey: string)

Update the ApiKey for an instance

myIm.setImApiKey('new apiKey')

getUserInfo(address?: string)

Acquire a user's basic information

Parameter

Type

Description

Default

address

string

Optional. To specify a user's relationId or web3 address. Empty means querying oneself.

getFollowing(data: { address: string, cursor?: string, limit?: number })

To acquire a list of the people the user is following.

Parameter

Type

Description

Default

address

string

Required. To specify a user's relationId or web3 address.

cursor

string

The cursor data returned by the last page(optional). If cursor is empty, then you are querying the first page.

limit

number

How much data should be returned per page(optional). The upper limit is 100.

20

recommend(data: { address: string, cursor?: string, limit?: number })

The recommendation engine will recommend potential friends based on these factors: the user's Twitter followers, transactions on the Ethereum chain, NFT holdings, and users in the lists of following.

Parameter

Type

Description

Default

cursor

string

The cursor data returned by the last page(optional). If cursor is empty, then you are querying the first page.

limit

number

How much data should be returned per page(optional). The upper limit is 100.

20

follow(address: string)

To follow a user

Parameter

Type

Description

Default

address

string

Required. To specify a user's relationId or web3 address.

unfollow(address: string)

To unfollower a user

Parameter

Type

Description

Default

address

string

Required. To specify a user's relationId or web3 address.

sendMessage(data: sendMessageType)

To send a message. The data structure sendMessageType has the following parameters:

Parameter

Type

Description

Default

content

string

content of the message

Required. The text content.

channelUuid

string

Required. The uuid of the channel.

-

toRelationId

string

Optional. The receiver's relationId

-

sendUuid

string

Optional. The uuid of the message

type

string

Optional. The message type.

TEXT

Note: channelUuid and toRelationId cannot be empty at the same time. If the sendUuidis empty, the system will connect the current timestamp and a random number with channelUuid and toRelationId as the default sendUuid.

If you are sending a message to a user never had a conversation before, once the message is sent, a new channel will be created automatically and its channelUuid will be returned.

userChannelsList(data: listRequestType)

To acquire a user's list of channels. The parameters of listRequestType are as follows:

Parameter

Type

Description

Default

keyword

string

Optional. Descending order.

The name of the channel. Fuzzy search is supported.

cursor

string

The cursor data returned by the last page(optional). If cursor is empty, then you are querying the first page.

limit

number

How much data should be returned per page(optional).

20

messageList(data: messageListRequestType)

To acquire the list of messages of a channel for a user. The parameters of messageListRequestType are as follows:

Parameter

Type

Description

Default

maxCreateAt

number

Required. A timestamp based on milliseconds. It needs to be greater than the timestamp of the last message sent on the current page.

-

channelUuid

string

Optional. UUID of the channel.

-

toRelationId

string

Optional. The receiver's toRelationId .

-

limit

number

How much data should be returned per page(optional).

50

channelCreate(data: {members, name, type})

To create a new channel

Parameter

Type

Description

Default

name

string

Required. The name of the channel.

type

string

Group Chat Type, enumerated as: G-Regular Group Chat, P-p2p Group Chat

members

string[]

The collection of group members' relationId. If type=P, then it will only see the caller and the first user as group chat members. The admin of the group chat is the current caller.

-

channelInfo(channelUuid: string)

To acquire the details of a channel.

Parameter

Type

Description

Default

channelUuid

string

Required. The uuid of the channel.

-

channelDisband(channelUuid: string)

dismiss a channel

Parameter

Type

Description

Default

channelUuid

string

Required. The uuid of the channel.

-

channelMemberLeave(channelUuid: string)

when the current user choose to leave a channel.

Parameter

Type

Description

Default

channelUuid

string

Required field. The UUID of the channel.

-

Last updated