What is REST?
REST, or Representational State Transfer, is an
architectural style for providing standards between computer systems on the
web, making it easier for systems to communicate with each other.
REST-compliant systems, often called Restful systems, are characterized by how
they are stateless and separate the concerns of client and server. (Wikipedia)
Restful Web Services is a lightweight, maintainable, and scalable service that is built on the REST architecture. Restful Web Service, expose API from your application in a secure, uniform, stateless manner to the calling client. The calling client can perform predefined operations using the Restful service. The underlying protocol for REST is HTTP. REST stands for Representational State Transfer
- Difference between REST API s and Database
- The main purpose of database is to store data.
- But REST APIs about how components interact with each other.
- In REST APIs we are transferring the state of something over some protocol (HTTP).
- The something means a Resource.
- The state means A snapshot of the resource.
Let’s take an example.
Imagine about a textile shop. When customer requests a cloth from the shop representative, shop representative checks it in the store and returned to the customer.
Here customer is like the application and shop representative is like the
API. Cloth store is the database. When data is requested, data is returned by the
API. That is the basic idea about API.
Let’s think about a very normal process that we are very familiar.
If we want to fetch data from database we can just simply
run a query without using API. Then why we use API?
When we use API we can get overall business logic of the Application
to a centralized position.
Let’s take Facebook is as an example
We can access Facebook Application in different ways.
- Web Application
- Android Application
- IOS Application
- Messenger Application
- Facebook Lite Application
So one of common operation of all these applications is news feed. If you load Facebook application in web or android platform the same data with the view is loading.
So we have to
write that logic in all applications. But if we use API instead of writing the same
thing in all applications we can write it in one place, that one place is API
endpoint. Otherwise it will cause redundant problem. If we use API even we
access from web or mobile platforms same data will be loaded. As well as if we want to do change that business
logic we can do it from one place (API endpoint) instead of changing it in
every applications.
Giant clients in the environment like Facebook , Google and Microsoft , they give
their services through these APIs for outside developers.
Ex: Google Map API
If we want data from Google Map API , we can use google map API and get server details and integrated into our application
Let’s look at API crud operations. API crud operations use
http methods.
Crud Operation HTTP method
Create -
Delete -
Update -
Retrieve -
API Security
If there is not proper security mechanism, users will do
anything by accessing to those provided APIs.
Assume there is a need to use Google mail API , in order to access that there is an API key generated by the APIs for the users and in order to get those accesses we have to log from a Google account. Then Google knows this key is generated for that specific user when we access through that API key. So when user access those services through API google can validate the user with that generated key.
So API is a mechanism that made to transfer data among two components.So in this article, mainly focus on the basic idea of API.
References :
Comments
Post a Comment