Using an API to scrape is legal as long as you are scraping data that is readily accessible to public. However, you need to cautious not to scrape data like confidential data, intellectual property, and personal information.