What is the difference between API-based testing and UI-based automation, and when would you prioritize one over the other?