Using the shopify API, you can see when an item is published to your store. You can also set your store so that when an item sells out, it automatically becomes unpublished. Is there a way to see at what time that occurs? Alternatively, is there a way to find the time at which the inventory for an item reaches 0?
You could periodically ping the API but there's a good chance that something will slip by. I would say a better way would be to use a webhook that will notify you when an order is placed. That way you only check when you need to and you'll be updated in real time.