ihaider
ihaider

Reputation: 1350

API vs WebService - Confusion on usage - Real world example required

I understand most of you will think that this is a redundant question, but I'm confused and have to clear it. I've searched it on Google, have seen dozen of questions and answer but no success.

The part that's creating more confusing is, where we use WHAT (api or web service) ? I don't want to start debate over API vs Web Service here I just need a good example in simple words that will tell where we exactly uses APIs and where we uses Web Services, I guess that will be really helpful to understand. A Good real world example, may be.

Thanks for your time.

Upvotes: 1

Views: 1660

Answers (4)

kulatamicuda
kulatamicuda

Reputation: 1651

Not sure what you mean by API - the REST ? The WS is also kind of API (Application programming interface).

If you mean REST vs WS - here are some practical comments from me:

REST

  • more lightweight than WS, but you have to do everything by yourself (security, parsing, ...). In WS you have it all via WS-I*.

  • now more popular in web development because of lighweight and JSON etc.

WS

  • more tools available and in corporate bank, telco or utilities environment is more popular (from my practice).

It is sometimes useful to provide both API - REST and WS.

Practical sample - our archiving solution which is used in enterprise has it's native API based on REST only. It is because whole development is based on lightweight principle and REST maches better and is better maintained by us. For those implementations where customer wants WS we use simple bridge.

Last but not least recommendation is - use the one what is better for you, both are good.

Upvotes: 0

Avijit
Avijit

Reputation: 1229

A web service typically offers a WSDL from which you can create client stubs automatically. Web Services are based on the SOAP protocol. Web API is a newer Microsoft framework which helps you to build REST based interfaces. The response can be either JSON or XML, but there is no way to generate clients automatically because Web Api does not offer a service description like the WSDL from Web Services. So it depends on your requirements which one of the techniques you want to use.Just look at the MSDN documentation or more details.

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) very slow.

Eg. In WebAPI you can pack the data, send it compressed and un-compress+un-pack on the client.

Upvotes: 0

Oli Callaghan
Oli Callaghan

Reputation: 336

Ok, in regards to your question, a Web Service is a type of API, but it is Web Based. Developers can hook up code to this, which can communicate back with their own code, to do something. An example of this would be the Oxford Dictionary API, in which you can send it a word, and it will reply with their meanings.

An API on the other hand, doesn't have to be web based, so for example, OpenGL, or SpriteKit are examples of non-web based APIs which you can supply with data for it to manipulate and output.

Hope this helps!

Oli

Upvotes: 2

Tencho Tenev
Tencho Tenev

Reputation: 91

In my opinion, if we consider an API is actually some kind of web API it is the same as a web service. Having said that, an API has a broader meaning as explained here. APIs are used outside the web, too

Upvotes: 0

Related Questions