How to SET PROPERTIES programmatically

The Set properties plugin seems to apply the same value to all the records in my data file.
I have a scenario where I need to be able to set different values for my property based on a combination of conditions.

One way would be to use the Metadata Sequencer to split per record and set a variable property value.
The process has taken a huge performance hit as a result.

Is there an API I can use in a Run Script to loop through all records at once and set my property value based on my conditions?

Yep. Look here for a list of all available APIs: PlanetPress Workflow Workflow 2019.2 User Guide

The ones you want are the Metadata API and the Connect REST API Cookbook.

You could set properties dynamically on the Content Item in a PostPagination script in your Connect template:

Example:
Selector: [section ^=‘Invoice_’]
This selector targets all sections which starts with Invoice_

contentitem.properties.PROPERTYNAME = record.fields.FIELDNAME

or you could write your expression there.
Ex:
contentitem.properties.PROPERTYNAME = record.fields.FIELDNAME ==‘X’ ? ‘XYZ’ : ‘012345’;

Obviousvly your expression could more complex than that. You get it…

Then in Workflow use the RETRIEVE ITEM plugin on the Content Item to obtain the content items which satisfy your retrieving conditions.