The purpose of this blog is to happily share my learning and ideas to help people, who actively seek solutions for the day-to-day problems faced.

Recent Posts

REST API - Explained

Introduction

There are times when we used to listen certain things often but not quite sure about what it exactly means/does or whatever (Most of them are just Greek & Latin, at least to me :P),  once such thing is REST API !!

I was not sure about what it exactly means and does before getting my hands-on on it. So the explanation goes below as

REpresentational State Transfer Application Programming Interface - REST API

Still come on yaar, what it means !!

Lets split this into two parts,
  1. Representational State Transfer
  2. Application Programming Interface
Now one by one,

Representational State Transfer:

Everything on the internet is accessed via URL, which stands for Uniform Resource Locator. 


  • https - Protocol
  • ravic499.blogspot.con - FQDN (Fully Qualified Domain Name or IP address)
  • 2019/07/how-to-research-stocks-for-investment.html -  Path to the resource

So every request we make are to access resources available in the Internet via http protocol (https in case of a secured connection). For each request we send to the web server we receive corresponding response in the form of web page (mostly in html or php) back to the client (eg: browser).

Client <-> Server
  • Client - Google Chrome Web Browser
  • Server - Web Server (Google's Blogger Server)
Request <-> Response
  • Request - GET Request URL to a resource path
  • Response - Web Page presented in html/php or JSON/XML
REST API Structure

Web server doesn't send you the actual database entry or the actual raw resource but rather a representation of the actual resource present in the form of human readable html or php format or easy to readable format for programmers like JSON or XML and other formats.

So whenever you click on a URL its resource representation is presented back to the user and as you click/navigate through successive pages, the web application page state is getting changed and the same is transferred and presented back to the user as response.

Hence each URL requests results in verb + URL, verbs are nothing but CRUD (Create/Read/Update/Delete) operations
  • GET
  • POST
  • PUT
  • DELETE etc
GET - used to read a web page information (reading a tweet)
POST - used to register/sign up into a website (posting a tweet)
PUT - used to modify an existing information (modifying a tweet)
DELETE - used to delete a information (deleting a tweet)

Application Programming Interface:
The ultimate goal of a web application is to access the application via a medium, which is nothing but the APIs. Hence the REST API, it made up of REST API endpoint URL + API method + additional parameters

APIs are nothing but a group of useful methods to perform desired operations. Here the additional parameters (not compulsory) are passed to this methods just like a normal programming language to return the expected response but remember here the response are not of html/php based output, it's mostly of JSON/XML based output. Later this responses are processed further by the UI/Front-end Team to present it better understandable to the user.

REST API - https://api.twitter.com/1.1/statuses/update.json?status=Hello
  • REST API endpoint URL - https://api.twitter.com/1.1/
  • API method - statuses/update.json
  • additional parameters - status=Hello
Hope you all understood what REST API is all about. Thanks for checking this out.

Please feel free to share your feedback.

Reference:

No comments