API (an application programming interface) is set of rules, protocols, specifications and tools which allows two software programs to communicate with each other for developing software and application. It provides interface to communicate two different software programs to interact with each other if both follows API’s protocols and rules. API is not user interface but it provides software to software interaction.
Web Services
Web service is application component or we can say client server application which use standardized XML messaging system for communication over the internet. We can communicate two devices over the network using web service. Web services allows you to expose your existing code functionality over the internet and others can use that functionality on their website.
Web service is independent from operating system and programming languages as it exchange information using XML. So you can establish information exchange between two different OS(Unix to Windows) and languages(Java to PHP) using web service.
Example :
- Company X is running website which offer hotel booking service and peoples are very comfortable to book hotel through that website. Website is developed in Java.
- Same way company Y is running flight booking website and it is also popular. Website is developed in PHP.
- Now supposing company Z wants to build a site in .Net which offer hotel + flight booking service. So company Z have 2 options. Either develop everything on their own (Which can take more money, time and effort) or use existing website functionality of company X and Y.
- So here company X and Y will expose their website code functionality using web services and company Z will use it to build their website. So here, Company Z don’t need to code everything again as they will access and use company X and Y’s functional code using web service.
Types of web services
There are mainly two types of web services available.
1. Big web services – Big web services follows SOAP(Simple Object Access Protocol) standard which use use XML messaging between web service to exchange the information.
2. RESTful Web Services – RESTful web services are based on the way how our web works.