Contacts

list()

api.mail.contacts.list() → Promise<Contact[]>

Every contact of the account, with its name and the address of its photo.

freeaccount-wideabsolute photo address
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

for (const contact of await api.mail.contacts.list()) {
  console.log(contact.address, contact.name, contact.image);
}
for contact in api.mail.contacts.list():
    print(contact["address"], contact.get("name"), contact.get("avatar"))
addressstring

The correspondent's address — the key.

namestring

What to show instead of the address.

imagestring|null

An absolute address for the photo, or null.

They belong to the account

Not to a mailbox. A contact saved once applies to every mailbox of the account — which is what you want, since the same person writes to several addresses.

The photo address is stable and cacheable

Not a short-lived signed link

A signed link would die in a list left open, the way message attachments do. A new photo gets a new address instead, which expires browser caches by itself.

Building a picker

const byAddress = new Map((await api.mail.contacts.list()).map((c) => [c.address, c]));
const display = (address) => byAddress.get(address)?.name ?? address;
by_address = {c["address"]: c for c in api.mail.contacts.list()}
def display(address): return (by_address.get(address) or {}).get("name") or address