Skip to main content

Fetch chats overview

These APIs are useful for fetching list of all chats (or chat requests) that a user might have, along with providing calls to get latest message or historical messages between two users (or from a group).

Chat list API

List all chats that the user are already messaging with, called chat connections. While chat requests are request from other users (or invite from group) that you haven't accepted yet. See chat requests for more info.

// userAlice.chat.list(type, {options?})
const aliceChats = await userAlice.chat.list('CHATS');

Chat list parameters

ParamTypeSubtypeDefaultRemarks
typeCHATS or REQUESTS--Type of Chats to be listed
optionsobject-Optional configuration properties for listing chat
-options.pagenumber1The page number for pagination
-options.limitnumber10The maximum number of items to retrieve per page

Note: Parameters in this style are mandatory.

Expected response
[
{
chatId: '6168440929ced5109c50534d40bb98a5e109ebf1d33df966ae898f002fac8973',
about: null,
did: 'eip155:0x14727F96dF61105661E78275D1A03C4F8aeff562',
intent: 'eip155:0x14727F96dF61105661E78275D1A03C4F8aeff562',
intentSentBy: 'eip155:0x14727F96dF61105661E78275D1A03C4F8aeff562',
intentTimestamp: '2023-08-29T08:05:03.000Z',
publicKey:
'{"key":"-----BEGIN PGP PUBLIC KEY BLOCK-----\\n\\nxsBNBGTt9AcBCADXjt9OEXDQyE7w2veaHqTUN9fALt7c+cubz2nhWfmD07M1\\n5Spm3ScT/4HdlPpUBYnGUKlCT09g663RvvmDzp8442vZhfYeKbetrcNFxfnp\\n+ePQGiLDY0h2FmjQGkmZGP43ZLyhNT4eCIGPcPSpzaWAKw4wgE/tW2hli5m/\\n7e8HFno+bHp2ycNoPJpdqhY77CJL9zPqFdctCPxI5r1/+xkVLcf+NZ+vD7mz\\nq8xVpu3Tij5Jb5ShDPQ3qqPsqdCcB/fpnEtAOT/Ryuf5Qqic/bDrzImfaIO9\\nYmdnuc6uQBR1s8WbLHmOsQvJhe2D8MtggV5HwHbkPqxXBmpGIJnMeLHZABEB\\nAAHNAMLAigQQAQgAPgWCZO30BwQLCQcICZBvKHl019glPAMVCAoEFgACAQIZ\\nAQKbAwIeARYhBEyKE1gcoT4IIxerrG8oeXTX2CU8AADltgf/dREUaHmfM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hzvR9NjZPmSXEeYqYw2CUPxzaLsKoSP4dbXE7Hl+sYJptzke7LE1StzH\\nG64gRgEYMCKvRZaPXYnPJXAZwDhijw==\\n=8aQd\\n-----END PGP PUBLIC KEY BLOCK-----\\n","signature":"DEPRECATED"}',
profilePicture:
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAsklEQVR4AcXBQY0DMRBE0Z+SCRhCsBhGAJiAYQwBgzGmZuDk2pPDSKPsqt57zNfzTVKPxX+K0ciEmTATZqXuSRajkdVjkcVoXKnHIovRyOqeZMJMmAmzEurcUffkF6FOJsyEmTAr3BTqXKks7hBmwkyYFb7UPflLdU+yUCcTZsJMmBW+hDong5O6J1diNE7EJWEmzIRZqccii9G4Eur8oh6LTJgJM2H2mK/nGyNhJsyE2QfJZChdHLm7QQAAAABJRU5ErkJggg==',
threadhash: 'bafyreiewla5iyd7rnvjw2c5w6dbab4zkyf2desbowzouijoea2jzakxz6i',
wallets: 'eip155:0x14727F96dF61105661E78275D1A03C4F8aeff562',
combinedDID:
'eip155:0x14727F96dF61105661E78275D1A03C4F8aeff562_eip155:0x84a9385e9b97df87b80c2e689997133703853874',
name: null,
groupInformation: null,
msg: {
fromDID: 'eip155:0x14727F96dF61105661E78275D1A03C4F8aeff562',
toDID: 'eip155:0x84a9385e9b97df87b80c2e689997133703853874',
messageObj: [Object],
messageContent: 'Hello Alice!',
messageType: 'Text',
timestamp: 1693316103747,
fromCAIP10: 'eip155:0x14727F96dF61105661E78275D1A03C4F8aeff562',
toCAIP10: 'eip155:0x84a9385e9b97df87b80c2e689997133703853874',
encryptedSecret:
'-----BEGIN PGP MESSAGE-----\n' +
'\n' +
'wcBMA3d9z8TNUuddAQf/U2hMcybh5mUt9FFen5tfZ52PaB0vc2G+wYYIsBfu\n' +
'zg58rgLy8uGMxvzhtCWhpIE91G62d8M4OmaDa+PLjs8SqyRoyih/9pt8P4cw\n' +
'UJVHHDcJNC9r6/AV4aZySdz5u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XZvIT\n' +
'nhbHhhOR47k2E0hiHjPv2t3ggrwkrw6ISDgV8qYcrnf7vEFeGHpeSc25QLJH\n' +
'pXCeeHhH7h4C9L3PEdMt8T+Ne36cfNiwTGdOavin/yfNES6k0kqZxP44hn1M\n' +
'ZBk4jfyaDUh70mv4FtxdPcdb1TGQsPC1YYAIh/059EBqkdJFhVF4+A==\n' +
'=DBch\n' +
'-----END PGP SIGNATURE-----\n',
sigType: 'pgpv2',
verificationProof:
'pgpv2:-----BEGIN PGP SIGNATURE-----\n' +
'\n' +
'wsBzBAEBCAAnBYJk7fQHCZBvKHl019glPBYhBEyKE1gcoT4IIxerrG8oeXTX\n' +
'2CU8AADsmwf/UpJCmnqztJLt1Ltg0OD7xoDvumitRwkfhnXzUdBWxM3i7vj4\n' +
'cfjtcpQI2R5W0TXj9e2fymimIc98kjUqpDiUIaVAuD0OnEbJdIluGLBTJeks\n' +
'YTRikqkgjFJT9Y6/2VRQj59IR0rgC0sec8mSKPlxuhixkdSS7Wec0+84cGmX\n' +
'aieskReKeitKacYkU4Uf82Klc7Ft8+duBsaMGR3TS22PzHfYIHmy+8Z3b1SK\n' +
'pMyJ8NBXCG2F+05WdoUsXBR+lO74RjSDWnWZlgRngWjjvSXQuZ/QznIyBVmQ\n' +
'oOxJM5LSCCwH6ch5J/HmXudJG+3wsCINchvSQx0LntZUoeSp8cezvg==\n' +
'=KUqZ\n' +
'-----END PGP SIGNATURE-----\n',
link: null,
},
},
];
ParamTypeRemarks
msgIMessageIPFSmessage object
didstringuser DID
walletsstringuser wallets
profilePicturestringuser profile picture
publicKeystringuser public key
aboutstringuser description
threadhashstringcid from the latest message sent on this conversation
intentstringaddresses concatenated from the users who have approved the intent
intentSentBystringaddress of the user who sent the intent
intentTimestampnumbertimestamp of the intent
combinedDIDstringconcatenated addresses of the members of this chat (for DM the 2 addresses and from Group the addresses from all group members)
cidstringcontent identifier on IPFS
chatIdstringchat identifier
groupInformationGroupDTOif group chat, all group information

Fetch latest chat API

Fetches latest chat between your instantiated user and any other user (or group).

// userAlice.chat.latest(recipient)
const aliceChats = await userAlice.chat.latest(bobAddress);

Fetch latest chat parameters

ParamTypeDefaultRemarks
recipientstring-Recipient supports a number of address format including wallet addresses, chain agnostic wallet addresses, NFT addresses or even chatid which is useful for groups

Note: Parameters in this style are mandatory.

Expected response
[
{
link: 'bafyreibfikschwlfi275hr7lrfqgj73mf6absailazh4sm5fwihspy2ky4',
toDID: 'eip155:0xb340E384FC4549591bc7994b0f90074753dEC72a',
encType: 'pgp',
fromDID: 'eip155:0x0F1AAC847B5720DDf01BFa07B7a8Ee641690816d',
sigType: 'pgp',
toCAIP10: 'eip155:0xb340E384FC4549591bc7994b0f90074753dEC72a',
signature:
'-----BEGIN PGP SIGNATURE-----\n' +
'\n' +
'wsBzBAEBCAAnBQJjh5tjCRBaJmgmByp5FRYhBJC23yBJT2d/pTAID1omaCYH\n' +
'KnkVAAAZmwf/buPLw6caSZmYnw6D3/p6HF1kWlkGUOTP4RasaU/6dkeDaZs9\n' +
'SJlz2wC8oOpBGWHMJ/5n3ZWmU71E6U7IKIY793MyIv5t32vTNkwsRHUX7IIn\n' +
'QFF+FzTIEtHHVTRlnkqNR2YUk1kqcpZCZWHfahi5W2d/WkXlFNdvyyFH4W8L\n' +
'd03FGhOyXbWwU3xicBz5mSBpIFaaSCXl1SdgJDPXLSk3b65EEOjCOaiz85xC\n' +
'G+6SW4RUzCGSDcOd9F2EXvvY5H9LgQNi1jjlZn6JrPTPJTJ+wXZXzcZmtOXG\n' +
'EKcwvPbbPY9wd+gavRSOgYLYn5xoZQW/o3hW7AQlbC5Kj6js48Z0HQ==\n' +
'=qLiJ\n' +
'-----END PGP SIGNATURE-----\n',
timestamp: 1669831523684,
fromCAIP10: 'eip155:0x0F1AAC847B5720DDf01BFa07B7a8Ee641690816d',
messageType: 'Text',
messageContent: 'Hi',
encryptedSecret:
'-----BEGIN PGP MESSAGE-----\n' +
'\n' +
'wcBMA1fn1CNqxQ7nAQgArlo75qe54WerfRKFv1+F9j4NRMvSTgUztvIe51eg\n' +
'd5MVuj6RYxKERr2bTuBt5cMDJMlNuTnBBkPe4L8+SlsI46L9wmXV9xLoZq1a\n' +
'94JdxD98RGMF99Jde/3hC/X6GS1yVqPpKPKdWx/tkOPeyqeO/wFF7kqShgIi\n' +
'Wgq6hGz1fzD3GZhKGY0VSLuC3s0aUy/qw5En1Xd0uX0jdXBl07IIj8p1G2zx\n' +
'9BuVlksSK34yvIc0RQfCeRadMHkxbA0Hyj31Wrr+Y310YLTppL0s5bQR9APL\n' +
'WHsIztJ1fHTnXsPhnA7YG0SQpHTyJhuX3rgBjxGrvbZBArmZ+R/Pq9IkOkJe\n' +
'z8HATAMOsbaZjGN5JwEH/jYjLN6AFRWeaB5CSBSAF+CvHsUgadGmxTdSHBM6\n' +
'LM9rfGg/MCnpRBuHckA0NNZh+wepq6TDA54ZopsdP14gHj4MKCdfqZr86Jft\n' +
'ldtjeSgPTFEEJxPMJ4/Z3UeFU9rvOgfxX6l0eHWS0MYwJ3sVYvSyqqHir1K5\n' +
'TRdEIgtQ3NvLTKkX4bKTSU+SInrvDA+wsc2BcBsbgNhRiGb+XYrbqXBshL1a\n' +
'lIdpnomkAQgOZMO2n347uURYoruH3OtFeNABJ9D/nEU+LdhDOPGZPefvPBc5\n' +
'BxK4ExKZ2Wo/TZw8lgC53uqOljsGV63Hp71LkyesKWu5/+vdVrYx/vU63shh\n' +
'x/TSQAEiaFYEfkWSOthtH0nrJHhkY7FWgjp/1bj/J4J9HCQrVtt2WlQfhowZ\n' +
'ILxhKk/vep0sJviM3SfJ4hPtoYpZESc=\n' +
'=43Ta\n' +
'-----END PGP MESSAGE-----\n',
},
];
ParamTypeRemarks
fromCAIP10stringsender address
toCAIP10stringreceiver address
fromDIDstringsender did
toDIDstringreceiver did
messageTypestringmessage type
messageContentstringmessage content
signaturestringsignature of the message
sigTypestringsignature type
linkstringcontent identifier of the previous messages
timestampnumbertimestamp of the message
encTypestringencryption type
encryptedSecretstringencrypted secret

Fetch chat history API

Fetches historical messages between your instantiated user and any other user (or group).

// userAlice.chat.history(recipient. {options?})
const aliceChatHistoryWithBob = await userAlice.chat.history(bobAddress);

Fetch chat history parameters

ParamTypeSubtypeDefaultRemarks
recipientstring--Target DID ( For Group Chats target is chatId, for 1 To 1 chat target is Push DID )
optionsobject w--Optional Configuration for fetching chat history
-options.referencestring or null-Refers to message refernce hash from where the previous messages are fetched. If null, messages are fetched from latest message
-options.limitnumber10No. of messages to be loaded

Note: Parameters in this style are mandatory.

Expected response
[
{
link: 'bafyreibfikschwlfi275hr7lrfqgj73mf6absailazh4sm5fwihspy2ky4',
toDID: 'eip155:0xb340E384FC4549591bc7994b0f90074753dEC72a',
encType: 'pgp',
fromDID: 'eip155:0x0F1AAC847B5720DDf01BFa07B7a8Ee641690816d',
sigType: 'pgp',
toCAIP10: 'eip155:0xb340E384FC4549591bc7994b0f90074753dEC72a',
signature:
'-----BEGIN PGP SIGNATURE-----\n' +
'\n' +
'wsBzBAEBCAAnBQJjh5tjCRBaJmgmByp5FRYhBJC23yBJT2d/pTAID1omaCYH\n' +
'KnkVAAAZmwf/buPLw6caSZmYnw6D3/p6HF1kWlkGUOTP4RasaU/6dkeDaZs9\n' +
'SJlz2wC8oOpBGWHMJ/5n3ZWmU71E6U7IKIY793MyIv5t32vTNkwsRHUX7IIn\n' +
'QFF+FzTIEtHHVTRlnkqNR2YUk1kqcpZCZWHfahi5W2d/WkXlFNdvyyFH4W8L\n' +
'd03FGhOyXbWwU3xicBz5mSBpIFaaSCXl1SdgJDPXLSk3b65EEOjCOaiz85xC\n' +
'G+6SW4RUzCGSDcOd9F2EXvvY5H9LgQNi1jjlZn6JrPTPJTJ+wXZXzcZmtOXG\n' +
'EKcwvPbbPY9wd+gavRSOgYLYn5xoZQW/o3hW7AQlbC5Kj6js48Z0HQ==\n' +
'=qLiJ\n' +
'-----END PGP SIGNATURE-----\n',
timestamp: 1669831523684,
fromCAIP10: 'eip155:0x0F1AAC847B5720DDf01BFa07B7a8Ee641690816d',
messageType: 'Text',
messageContent: 'Hi',
encryptedSecret:
'-----BEGIN PGP MESSAGE-----\n' +
'\n' +
'wcBMA1fn1CNqxQ7nAQgArlo75qe54WerfRKFv1+F9j4NRMvSTgUztvIe51eg\n' +
'd5MVuj6RYxKERr2bTuBt5cMDJMlNuTnBBkPe4L8+SlsI46L9wmXV9xLoZq1a\n' +
'94JdxD98RGMF99Jde/3hC/X6GS1yVqPpKPKdWx/tkOPeyqeO/wFF7kqShgIi\n' +
'Wgq6hGz1fzD3GZhKGY0VSLuC3s0aUy/qw5En1Xd0uX0jdXBl07IIj8p1G2zx\n' +
'9BuVlksSK34yvIc0RQfCeRadMHkxbA0Hyj31Wrr+Y310YLTppL0s5bQR9APL\n' +
'WHsIztJ1fHTnXsPhnA7YG0SQpHTyJhuX3rgBjxGrvbZBArmZ+R/Pq9IkOkJe\n' +
'z8HATAMOsbaZjGN5JwEH/jYjLN6AFRWeaB5CSBSAF+CvHsUgadGmxTdSHBM6\n' +
'LM9rfGg/MCnpRBuHckA0NNZh+wepq6TDA54ZopsdP14gHj4MKCdfqZr86Jft\n' +
'ldtjeSgPTFEEJxPMJ4/Z3UeFU9rvOgfxX6l0eHWS0MYwJ3sVYvSyqqHir1K5\n' +
'TRdEIgtQ3NvLTKkX4bKTSU+SInrvDA+wsc2BcBsbgNhRiGb+XYrbqXBshL1a\n' +
'lIdpnomkAQgOZMO2n347uURYoruH3OtFeNABJ9D/nEU+LdhDOPGZPefvPBc5\n' +
'BxK4ExKZ2Wo/TZw8lgC53uqOljsGV63Hp71LkyesKWu5/+vdVrYx/vU63shh\n' +
'x/TSQAEiaFYEfkWSOthtH0nrJHhkY7FWgjp/1bj/J4J9HCQrVtt2WlQfhowZ\n' +
'ILxhKk/vep0sJviM3SfJ4hPtoYpZESc=\n' +
'=43Ta\n' +
'-----END PGP MESSAGE-----\n',
},
{
link: null,
toDID: 'eip155:0x0F1AAC847B5720DDf01BFa07B7a8Ee641690816d',
encType: 'PlainText',
fromDID: 'eip155:0xb340E384FC4549591bc7994b0f90074753dEC72a',
sigType: '',
toCAIP10: 'eip155:0x0F1AAC847B5720DDf01BFa07B7a8Ee641690816d',
signature: '',
timestamp: 1669831499724,
fromCAIP10: 'eip155:0xb340E384FC4549591bc7994b0f90074753dEC72a',
messageType: 'Text',
messageContent: 'Hey Fabio!',
encryptedSecret: '',
},
];
ParamTypeRemarks
fromCAIP10stringsender address
toCAIP10stringreceiver address
fromDIDstringsender did
toDIDstringreceiver did
messageTypestringmessage type
messageContentstringmessage content
signaturestringsignature of the message
sigTypestringsignature type
linkstringcontent identifier of the previous messages
timestampnumbertimestamp of the message
encTypestringencryption type
encryptedSecretstringencrypted secret