Apply tags to contacts by email addresses

Given a list of emails from a third-party source, what would be the most efficient method to apply tags to each?

I understand that I need to convert the emails to contact_ids before using

Currently, I am using
to get the ids of each contact, but it seems pretty inefficient to go through potentially hundreds of email addresses one at a time to construct a list of ids.

I have tried something like,
to get multiple at a time, but that doesn’t seem to work when filtering on the email field.

Is there anything that uses fewer API calls than what I’m currently using?

Unfortunately we don’t support “or” queries in the filter lists, so the only other method that I would expect is to keep a local hashmap cache of the contacts keyed by <email,id>.

You can keep the last id that you retrieved and pass it as a page_token parameter to see if newer contacts have been added just before you perform your operation, page through them to add to the cache, then construct your applyTags calls from that.