Skip to main content

Rest API

 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
People think REST API are Databases. My main purpose is to solve the conflict between this REST API and databases because when REST API are used by the developers , they treat REST APIs as databases.

  • 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                        -   POST

Delete                        -   DELETE

Update                       -   PUT

Retrieve                     -   GET

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 :

(155) What is an API? | Explained in Sinhala - YouTube








Comments

Popular posts from this blog

MongoDB vs MySQL

  MongoDB and MySQL are two databases that are used by developers when implementing various enterprise applications. Let's compare and contrast these two databases according to the following topics What is MongoDB and MySQL? Differences Why Use ? Disadvantages When to Use? What is MongoDB and MySQL? MongoDB MySQL MongoDB is an open-source database developed by MongoDB, Inc. MongoDB stores data in JSON-like documents that can vary in structure. It is a popular NoSQL database. MySQL is a popular open-source database developed, distributed and supported by Oracle Corporation. It    relational database management system (RDBMS) that is developed, distributed and supported by Oracle Corporation Differences NoSQL vs SQL NoSQL databse              SQL database No need predefined structure Need predefined structure   Non-Relational Database Relational Database Data as of JSON documents Represents data table and...

Version Control

  In  software engineering ,  version control  is a class of systems responsible for managing changes to  computer programs , documents, large web sites, or other collections of information. Version control is a component of  software configuration management .  [Wikipedia] Other names       –       Revision control , Source control , Source code management Version Control Systems  They are software tools that help software teams manage changes to source code over time. Version control software is an essential part of the every-day of the modern software team's professional practices. Using version control systems, several developers, designers, and team members will work on the same project. These systems, also known as version control systems or VCS, ensure that everybody has access to the most current code. Why Version Control system is so Important?      Groups of software developers ar...