Documentation Index
Fetch the complete documentation index at: https://mintlify.com/photon-hq/advanced-imessage-kit/llms.txt
Use this file to discover all available pages before exploring further.
getChats
Retrieve a list of chat conversations with optional filtering and pagination.
await sdk.chats.getChats(options?): Promise<ChatResponse[]>
Parameters
Optional configuration for querying chatsInclude the last message in each chat response
Include archived chats in the results
Number of chats to skip for pagination
Maximum number of chats to return
Returns
Array of chat objectsUnique identifier for the chat
Chat style (0 = individual, 43 = group)
Whether the chat is archived
Whether the chat is filtered
Group identifier for group chats
Array of participant handles (if requested)
Array of messages (if requested)
Most recent message in the chat (if withLastMessage is true)
Last addressed handle in the chat
Additional chat properties
Example
import { SDK } from '@photon-ai/advanced-imessage-kit';
const sdk = SDK({ serverUrl: 'http://localhost:1234' });
// Get all chats with last message
const chats = await sdk.chats.getChats({
withLastMessage: true,
limit: 50
});
console.log(`Found ${chats.length} chats`);
chats.forEach(chat => {
console.log(`${chat.displayName}: ${chat.lastMessage?.text}`);
});
// Get chats with pagination
const page1 = await sdk.chats.getChats({
offset: 0,
limit: 20
});
const page2 = await sdk.chats.getChats({
offset: 20,
limit: 20
});
// Include archived chats
const allChats = await sdk.chats.getChats({
withArchived: true
});
getChatCount
Get the total count of chats with optional breakdown.
await sdk.chats.getChatCount(options?): Promise<{ total: number; breakdown: Record<string, number> }>
Parameters
Optional configuration for counting chatsInclude archived chats in the count
Returns
Chat count informationBreakdown of chat counts by category
Example
import { SDK } from '@photon-ai/advanced-imessage-kit';
const sdk = SDK({ serverUrl: 'http://localhost:1234' });
// Get total chat count
const count = await sdk.chats.getChatCount();
console.log(`Total chats: ${count.total}`);
console.log('Breakdown:', count.breakdown);
// Include archived chats in count
const fullCount = await sdk.chats.getChatCount({
includeArchived: true
});
console.log(`Total chats (including archived): ${fullCount.total}`);