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
/v2/tags/225/contacts:applyTags

Currently, I am using
https://api.infusionsoft.com/crm/rest/v2/contacts?filter=email==billy@keap.com
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
https://api.infusionsoft.com/crm/rest/v2/contacts?filter=email==billy@keap.com,bob@keap.com
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.

https://api.infusionsoft.com/crm/rest/v2/contacts?&fields=email_addresses&page_token=16