What is the difference between a microservice and an API?

Microservices is an approach to building an application that breaks its functionality into modular components. APIs are part of an application that communicates with other applications.