Sunteți pe pagina 1din 6

Two things are very simple to understand,

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.

Difference between API and Web Service


API vs Web Service
API and Web service serve as a means of communication. The only difference is that a Web service
facilitates interaction between two machines over a network. An API acts as an interface between two
different applications so that they can communicate with each other. An API is a method by which the
third-party vendors can write programs that interface easily with other programs. A Web service is
designed to have an interface that is depicted in a machine-processable format usually specified in Web
Service Description Language (WSDL). Typically, HTTP is the most commonly used protocol for
communication. Web service also uses SOAP, REST, and XML-RPC as a means of communication. API
may use any means of communication to initiate interaction between applications. For example,
the system calls are invoked using interrupts by the Linux kernel API.
An API exactly defines the methods for one software program to interact with the other. When this
action involves sending data over a network, Web services come into the picture. An API generally
involves calling functions from within a software program.
In case of Web applications, the API used is web based. Desktop applications such as spreadsheets and
word documents use VBA and COM-based APIs which dont involve Web service. A server application
such as Joomla may use a PHP-based API present within the server which doesnt require Web service.
A Web service is merely an API wrapped in HTTP. An API doesnt always need to be web based. An API
consists of a complete set of rules and specifications for a software program to follow in order to
facilitate interaction. A Web service might not contain a complete set of specifications and sometimes
might not be able to perform all the tasks that may be possible from a complete API.
The APIs can be exposed in a number of ways which include: COM objects, DLL and .H files in C/C++
programming language, JAR files or RMI in Java, XML over HTTP, JSON over HTTP, etc. The method used
by Web service to expose the API is strictly through a network.

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-

1. Web Service is an API wrapped in HTTP.


2. All Web Services are API but APIs are not Web Services.
3. Web Service might not perform all the operations that an API would perform.
4. A Web Service needs a network while an API doesn't need a network for its operation

Web services are a specific subset of APIs.


APIs can have many forms, whether they communicate over the Web, over other Internet protocols, or even inter-
process on the same machine, or inside the same machine and process.
Web Service:
1) It is a SOAP based service and returns data as XML.
2) It only supports the HTTP protocol.
3) It can only be hosted on IIS.
4) It is not open source, but can be used by any client that understands XML.
5) It requires a SOAP protocol to receive and send data over the network, so it is not a light-weight architecture.

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.

Difference between API Vs. Web Services.


API (Application Programming Interface) is nothing but the protocol intended to be used as
an interface by software components to communicate with each other. An API acts as an interface between two
different applications so that they can communicate with each other.

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.

Benefits of REST Over SOAP


In addition to using HTTP for simplicity, REST offers a number of other benefits over SOAP:
REST allows a greater variety of data formats, whereas SOAP only allows XML.
Coupled with JSON (which typically works better with data and offers faster parsing), REST is generally considered
easier to work with.
Thanks to JSON, REST offers better support for browser clients.
REST provides superior performance, particularly through caching for information thats not altered and not
dynamic.
It is the protocol used most often for major services such as Yahoo, Ebay, Amazon, and even Google.
REST is generally faster and uses less bandwidth. Its also easier to integrate with existing websites with no need
to refactor site infrastructure. This enables developers to work faster rather than spend time rewriting a site from
scratch. Instead, they can simply add additional functionality.
Still, SOAP remains the preferred protocol for certain use cases. The general consensus among experts these days
is that REST is the typically preferred protocol unless theres a compelling reason to use SOAP (and there are some
cases in which SOAP is preferred).
Benefits of SOAP Over REST
Because you can achieve most outcomes using either protocol, its sometimes a matter of personal preference.
However, there are some use cases that SOAP tends to be better-suited for. For instance, if you need more robust
security, SOAPs support for WS-Security can come in handy. It offers some additional assurances for data privacy
and integrity. It also provides support for identity verification through intermediaries rather than just point-to-
point, as provided by SSL (which is supported by both SOAP and REST).
Another advantage of SOAP is that it offers built-in retry logic to compensate for failed communications. REST, on
the other hand, doesnt have a built-in messaging system. If a communication fails, the client has to deal with it by
retrying. Theres also no standard set of rules for REST. This means that both parties (the service and the
consumer) need to understand both content and context.
Other benefits of SOAP include:
SOAPs standard HTTP protocol makes it easier for it to operate across firewalls and proxies without
modifications to the SOAP protocol itself. But, because it uses the complex XML format, it tends to be slower
compared to middleware such as ICE and COBRA.
Additionally, while its rarely needed, some use cases require greater transactional reliability than what can be
achieved with HTTP (which limits REST in this capacity). If you need ACID-compliant transactions, SOAP is the way
to go.
In some cases, designing SOAP services can actually be less complex compared to REST. For web services that
support complex operations, requiring content and context to be maintained, designing a SOAP service requires
less coding in the application layer for transactions, security, trust, and other elements.
SOAP is highly extensible through other protocols and technologies. In addition to WS-Security, SOAP supports WS-
Addressing, WS-Coordination, WS-ReliableMessaging, and a host of other web services standards, a full list of
which you can find on W3C.
At the end of the day, the best protocol is the one that makes the most sense for the organization, the types of
clients that you need to support, and what you need in terms of flexibility. Most new APIs are built using REST and
JSON, simply because it typically consumes less bandwidth and is easier to understand both for developers
implementing initial APIs as well as other developers who may write other services against it. Because its more
easily consumed by most of todays web browsers, REST+JSON has become the defacto technology for the
majority of public APIs. However, SOAP remains a valuable protocol in some circumstances. Plus, you dont have to
look far to find die-hard fans advocating for SOAP for certain use cases
SOAP vs REST Web Services
There are many differences between SOAP and REST web services. The important 10 differences
between SOAP and REST are given below:

No. SOAP REST

1) SOAP is a protocol. REST is an architectural style.

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.

S-ar putea să vă placă și