Macotron

macotron.contacts

List and search the people in the Contacts app, with their names, company, email addresses, and phone numbers.

const [person] = await macotron.contacts.search("ada");
if (person && person.emails[0]) macotron.url.open("mailto:" + person.emails[0]);

People

Both calls read every contact in every account and run off the main thread. Each row has the same fields:

FieldMeaning
idThe contact's identifier.
nameThe full name, formatted the way Contacts shows it. "" for a contact with no name, such as a company card.
first, lastThe given name and family name.
organizationThe company name, or "".
emailsEvery email address, in card order.
phonesEvery phone number, as typed on the card.

list(): Promise<Array<{ id, name, first, last, organization, emails, phones }>>

Every contact.

search(query: string): Promise<Array<{ id, name, first, last, organization, emails, phones }>>

Contacts whose name, organization, email addresses, or phone numbers contain query. The match ignores case and accents, so "jose" finds José. An empty query returns every contact.

Macotron needs Contacts access. The first call asks macOS to show the permission prompt and resolves with [] while the user decides. If access is denied, every call resolves with []; turn it on in System Settings → Privacy & Security → Contacts.

See also