API / Web Services - Basics
What is web Service? Explain with an example?
Web service is a standardized communication medium between the client and server applications on the World Wide Web.
For example :- when we started searching anything on the google it will invoke different type of services like.. Search for the resources, getting the results from multiple websites, spelling check, fetch cache etc.
another example will be like if i want to show the temperature of the current city, instead of writing the logic to get the temperature of the city i can simply invoke API's which can help me with this feature.
In simple words..
Web Services are the services which is can be written by anyone else and we can just pass our input and get the output from that service.
It means we really don't need to know how exactly it is giving us the output but we are getting the desired output based on our input values.
A web service is a software module that is designed to perform a certain set of tasks.
API terminologies
Get :- Get action tells the system/ module that you want to fetch or retrieve the information.
Post :- With post api generally we create a new object and receive response code as 201, in case of successful completion of the object.
Put :- It is same as post, but it worked for the existing object, so we need some existing parameters and stuff/ change/updated values to work on that object also PUT is for complete entity replacement whereas PATCH is to partially update the entity.
Delete : Delete action just ask server to delete an existing object.
Patch :- Patch request says that we would only send the data that we need to modify without modifying or effecting other parts of the data. Ex: if we need to update only the first name, we pass only the first name also PUT is for complete entity replacement whereas PATCH is to partially update the entity.
Idempotency :- A action that will always results in the same server state, no matter how many times we call it is known as idempotency.
Type of API's
REST ( Representational State Transfer)
SOAP ( Simple Object Access Protocol )
Risk with API's
API structure keep on changing change
API logic change (any bugs )
response structure change
Post a Comment