Breaking

Saturday, June 29, 2019

What is a service in the software world?
Service is a function or method that can be used by the client. The function is nothing but a piece of code written in some programming language and that function/method executes over the server to provide services.
For Example:-
Some service(let's say Weather Service) is hosting on a server and you want to make use of it, then you need to just call it from your laptop/PC/mobile and the service will execute its logic gives it output for you. If any service is available on the server, you can make use of it. It's nothing but a method available in a server that we can use again and again. 



What is web service?
Any service that accesses over the web is a web service. That means any server hosting a service that is access-able on the internet and we need a protocol(like Http/Https) to access that service. Services are always available in the server, the client whoever wants to access that service needs to make a request for the service over the internet with some protocol. And the service got a request from the client in an XML format and run its logic to provide the output of the service and send this output to the client is also XML format. This is the basic structure of Client-server communication over the internet.

A similar way an application can communicate to web services for some specific information using API.

API(Application Programming Interface):-
API is not any programming language or any protocol or any service, it is an interface with which you can access the service(maybe Google, Facebook, or any other services) via a program. It provides the interface between a particular method of that service and the application. A service exposes its interface(API) and then a developer/programmer will access that functionality of that service in its program via that interface(API).

In a simple way, if you are developing any application and you need any data or information from an already developed web application/service having the same data/information, then API is the only way to communicate with that Service.
Understand by an Example:- 
In many applications, you might notice the login way given by them, that you may like to login using your Google account or your Facebook account.

Yes..! That is done by the API of Google and Facebook. Most companies like Google, Facebook, Dropbox, Office 365, or more other companies are exposing there APIs for developers. Developers can call a particular API exposed by the company to communicate with it and can exchange a limited amount of information (that decided by providing company) in JSON or any standard data format through API. That's how every application gets only your login information from Google or Facebook. 

API is not a web service. API calls don't always depend on an internet connection.

Few more Examples (No internet connection required):-
IBM or Canon or any printers, they have an API attached to it, if you want to print anything from your phone or laptop using your own application, then you can use that API in your application to send data to printer and printer will print it.

In an Operating System, there are many APIs opened to the user-level which are called system calls.
  
REST (Representational State Transfer):-
Rest is a design pattern, not a protocol...! What is the difference??
The protocol is a set of rules that has to follow to achieve service, If you break any rule you can't access that service. but design pattern is also based on some rules, But if you ignore some rule, still you can get the benefit from other rules.

REST is basically SIX concepts that have been proposed by professor Roy Fielding to exchange messages over the web between two systems. 

Any API/communication over the web between two systems follow these six design pattern called REST-based API/communication.

1. Client-Server
2. Stateless
3. Cacheable
4. Layered System
5. Code on demand
6. Uniform Interface  

Many rest services do not follow all the design patterns that Roy has proposed. Remember REST is a design pattern that doesn't have to follow all the 6 rules but there is some specific rule that has to follow otherwise it will not solve the purpose right.

To read more about the above six design pattern  click here 👈

Pictures:- Srinivas Vanamala


close