A web service is a network-based resource that performs a specific task, whereas an API is an interface that enables you to build software that interacts with an existing application. We can say, all web services are APIs, but not all APIs are web services.