API: It's an layer on application which can serve other application request locally.
Webs Service: Is an API which can serve request and respond over the network form remote system over the web
or internet. Note: All Web Service is API's but not all API' is web services
Web Services - that's standard defined by W3C, so they can be accessed semi-automatically or automatically
(WSDL / UDDI). The whole thing is based on XML, so anyone can call it. And every aspect of the service is very well
defined. There's parameters description standard, parameter passing standard, response standard, discovery
standard, etc. etc. You could probably write 2000 pages book that'd describe the standard. There are even some
"additional" standards for doing "standard" things, like authentication.
Despite the fact that automatic invoking and discovery is barely working because clients are rather poor, and you
have no real guarantee that any service can be called from any client.
Web API is typically done as HTTP/REST, nothing is defined, output can be for eg. JSON/XML, input can be
XML/JSON/or plain data. There are no standards for anything => no automatic calling and discovery. You can
provide some description in text file or PDF, you can return the data in Windows-1250 instead of unicode, etc. For
describing the standard it'd be 2 pages brochure with some simple info and you'll define everything else.
Web is switching towards Web API / REST. Web Services are really no better than Web API. Very complicated to
develop and they eat much more resources (bandwidth and RAM)... and because of all data conversions
(REQUEST->XML->DATA->RESPONSE->XML->VALIDATION->CONVERSION->DATA) are very slow.
Eg. In WebAPI you can pack the data, send it compressed and un-compress+un-pack on the client. In SOAP you
could only compress HTML request.
A Web Service allows for machine to machine communications over HTTP. A web API is a subset of web services
that use REST conventions (Summarizing the Wikipedia article). The concepts definitely overlap. I believe that
there is still a link in most people's minds of web service -> SOAP/XML-RPC which can unnecessarily confuse
matters.
Web services is a defined architecture and approach to a problem domain as stated by the W3C
Web API is a concept and abstracts the means on how the concept is implemented.
Summary:
1. All Web services are APIs but all APIs are not Web services.
2. Web services might not perform all the operations that an API would perform.
3. A Web service uses only three styles of use: SOAP, REST and XML-RPC for
Communication whereas API may use any style for communication.
4. A Web service always needs a network for its operation whereas an API doesnt need
a network for its operation.
5. An API facilitates interfacing directly with an application whereas a Web service is a
API:
An application programming interface (API) is a set of routines, data structures, object classes and/or protocols
provided by libraries and/or operating system services in order to support the building of applications.
Webservice:
A Web Service is defined by the W3C as "a software system designed to support interoperable machine-to-
machine interaction over a network"
Clearly, both are means of communications. The diference is that Web Service almost always involves
communication over network and HTTP is the most commonly used protocol. Web service also uses SOAP, REST,
and XML-RPC as a means of communication. While an API can use any means of communication e.g. DLL files in
C/C++, Jar files/ RMI in java, Interrupts in Linux kernel API etc.
So, you can say that-
Web API:
1) A Web API is a HTTP based service and returns JSON or XML data by default.
2) It supports the HTTP protocol.
3) It can be hosted within an application or IIS.
4) It is open source and it can be used by any client that understands JSON or XML.
5) It is light-weight architecture and good for devices which have limited bandwidth, like mobile devices.
Web Service is an API used in the context of web development. A Web service is a method of communication
between two electronic devices over the World Wide Web.
API use any means of communication to initiate interaction between applications. API has a complete set of rules
and specifications for a software program to interaction with each other.
A Web service may not have a complete set of specifications and sometimes might not be able to perform all the
tasks.
API can be stripped in a various ways: COM Object, DLL files, Header files with .h extension, RMI in java etc, linux
kernel API.
Web Services must be exposed the API is strictly through a network. Web Service API almost always uses HTTP or
SMTP. Web Services can be SOAP, XML-RPC, REST, etc.
Web API i.e. Web Service is typically defined as a set of Hypertext Transfer Protocol (HTTP) request messages,
along with a definition of the structure of response messages, which is usually in an Extensible Markup Language
(XML) or JavaScript Object Notation (JSON) format.
All Web services are APIs but all APIs are not Web services.
2) SOAP stands for Simple Object REST stands for REpresentational State Transfer.
Access Protocol.
3) SOAP can't use REST because it is REST can use SOAP web services because it is a
a protocol. concept and can use any protocol like HTTP, SOAP.
4) SOAP uses services interfaces to REST uses URI to expose business logic.
expose the business logic.
5) JAX-WS is the java API for SOAP JAX-RS is the java API for RESTful web services.
web services.
6) SOAP defines standards to be REST does not define too much standards like SOAP.
strictly followed.
7) SOAP requires more REST requires less bandwidth and resource than
bandwidth and resource than REST. SOAP.
8) SOAP defines its own security. RESTful web services inherits security measuresfrom
the underlying transport.
9) SOAP permits XML data format REST permits different data format such as Plain text,
only. HTML, XML, JSON etc.
10) SOAP is less preferred than REST. REST more preferred than SOAP.
API
An API is an Application Programming Interface, means by which third parties can write code that interfaces with
other code.
OR
An api is a collection of class which provide you some functionalities like google api gives you the opportunity to
work with the google search.
OR
An application programming interface (API) is a set of routines, data structures, object classes and/or protocols
provided by libraries and/or operating system services in order to support the building of applications.
WEB SERVICES
A Web Service is a type of API, almost always one that operates over HTTP (Though some, like SOAP, can use
alternate transports, like SMTP). The Official W3C Definition mentions that Web Services dont necessarily use
HTTP, but this is almost always the case and is usually assumed unless otherwise mentioned.
OR
A Web service (also Web Service) is defined by the W3C as a software system designed to support interoperable
machine-to-machine interaction over a network
OR
Webservices on the otherhand are services available over internet. You can call these services and get so
information or functionality in your application without actually having the classes or know how it works.