The Moto X comes with a feature that keeps the screen on when the user is looking at it. Is there an API that allows a third-party app to tell if the user is looking at the device?
Not in standard Android. Device manufacturers may offer ones specific for their devices.