Mark all rows in the table as “deleted” using a flag column.
Run an UPSERT custom query to insert/update table using API data as the source. Make sure to set flag column null or 0.
Delete all rows in the table which are still marked as “deleted”.
You can run these set of steps in a 1 minute scheduler, if using NodeJS. There, first step could be to check if there are any “deleted” rows in the table. If yes, it means previous execution is still running - so don’t start another execution. This will help with avoiding overlapping steps.