addressBooks.provider

The addressBooks.provider API first appeared in Thunderbird 90. It allows to add address books, which are not stored or cached by Thunderbird itself, but are handled completely by the extension. Address books created by the addressBooks.provider API will forward all access requests to the WebExtension. Possible use cases:

  • implement a custom storage

  • implement search-only address books querying a remote server

So far, only the API for search-only address books is implemented.

Warning

This API will change in future releases of Thunderbird.

Permissions

addressBooks

Read and modify your address books and contacts

Note

The permission addressBooks is required to use addressBooks.provider.

Events

onSearchRequest

Registering this listener will create and list a read-only address book in Thunderbird’s address book window, similar to LDAP address books. When selecting this address book, users will first see no contacts, but they can search for them, which will fire this event. Contacts returned by the listener callback will be displayed as contact cards in the address book. Several listeners can be registered, to create multiple address books.

The event also fires for each registered listener (for each created read-only address book), when the user types something into the mail composer’s To: field, or into similar fields like the calendar meeting attendees field. Contacts returned by the listener callback will be added to the autocomplete results in the dropdown of that field.

Example:

messenger.addressBooks.onSearchRequest.addListener(async (node, searchString) => {
    // Return an array of ContactProperties.
    let response = await fetch("https://people.acme.com/?query=" + searchString);
    return response.json.map(contact => (
        { 
            DisplayName: contact.name, 
            PrimaryEmail: contact.email
        }
    ));
}, {
    dirName: "ACME employees",
    isSecure: true,
});

Parameters for onSearchRequest.addListener(listener, parameters)

listener(node, searchString, query)

A function that will be called when this event occurs.

parameters

(object)

Descriptions for the address book created by registering this listener.

[addressBookName]

(string)

The name of the created address book.

[id]

(string)

The UID of the created address book. If several listeners have been added, the id allows to identify which address book initiated the search request. If not provided, a UID will be generated for you.

[isSecure]

(boolean)

Whether the address book search queries are using encrypted protocols like HTTPS.

Parameters passed to the listener function

[searchString]

(string)

The search text that the user entered. Not available when invoked from the advanced address book search dialog.

[query]

(string)

The boolean query expression corresponding to the search. Note: This parameter may change in future releases of Thunderbird.

Expected return value of the listener function

Required permissions

  • addressBooks