Skip to main content

getContacts()

Retrieves all contacts from the iMessage server.

Returns

contacts
array
required
Array of contact objects from the server.

Example

const contacts = await client.contact.getContacts();
console.log(`Found ${contacts.length} contacts`);
This method returns all available contacts. Use this to build a contact list or lookup contact information.

getContactCard()

Retrieves a contact card from iCloud for a specific address.

Parameters

address
string
required
The email address or phone number to look up in iCloud contacts.

Returns

contactCard
object
required
Contact card data from iCloud containing the contact’s information.

Example

const contactCard = await client.contact.getContactCard('+1234567890');
console.log('Contact name:', contactCard.name);

// Also works with email addresses
const emailContact = await client.contact.getContactCard('user@example.com');
This method queries iCloud directly, so the address must be associated with an iCloud account.

Use cases

  • Look up contact details before sending a message
  • Verify contact information exists in iCloud
  • Retrieve contact metadata for display purposes

Error handling

try {
  const contactCard = await client.contact.getContactCard('unknown@example.com');
} catch (error) {
  console.error('Contact not found or iCloud query failed:', error);
}

Build docs developers (and LLMs) love