What is APi


API :Application Programming Interface.


If One Application want to Communicate with Another Application 

the we may Require API


Interface here means Plateform


Web Application <-------Human

(HTML/CSS/FORMS/VIEWS/PAGE)

The html form,Admin Panel which you provide to any person as Interface where

he can Interact with You Application. 


if HUMAN want to Interact we provide some GUI Or Interface

but if One App1 want interact with Another Application  (Indepedent Of Lanaguge)

in such a case we need some Interface.

such Type of Interface B/w two Different  Programming Application is called

called API


For Example:

Android Application with Java Application

Android Application with PHP Application

Android Application with Mysql Application


Here there Are Two Main Application

Cleint App1 : Reqeust Sent

Server App2 : Response Return


Let us Understand API as a General Terminology

***********************************************


Consider 

Rail Yatri Application

Where is My Train Application

NTES CRIS Application

makemytrip Application

Ibibio Application

Paytm Application


All These Application Internally Sent the Request IRCTC


Web Api and Web Services

Since API is a Interface B/w two native(perticular Lanaguge) Application 

and Api provides some Kind of Third Party.


if this service is Accessed Using Internet

it is a Service Over the Web

Hence it is a Web Service or Api B/W two Application Sharing The resources

over the Internet is called is Web-Api.


Web Api are of Two Types

*************************

1. Soap Api : Conventional or Tradition Apis which generated Response Only 

in XML

2. Rest Api : is a Modern Apis Technique which generated Response in Json or YML.


SOAP Simple Object Access Protocal 

Rest: Representational State Transfer

Soap : Server Full

Rest : Server Less


Soap : Any Protocal Smtp,ftp,sftp,....http

Rest : HTTP(SSL Peer Off)/HTTPS (SSL Enabled Peer On)


Difference B/w Rest and Normal Web API


In Rest Api URL Remain Unique

and Every Request is Sent using HTTP METHODS

GET

PUT 

PATCH

POST

DELETE

LOCK

OPTIONS

HEAD

..etc


if any API Follows Following Condition it Is REST

1. it should only http/(s) protocol

2. JSON Format Output 

3. it Must Support http METHODS

4. Url should be Unique 

Url will same but will be unique according to different http METHODS

Rest Api will Crud

post Request Create (Insert)

GET Request read (Select)

put/patch Update PUT : Fully Update and Patch Partially Update

DELETE : Complete delete the Record


Note: Every Rest api is a Web-Api but every Api is not rest api

Difference B/w Rest and Soap


In Rest Format Json 

In Soap Format is Xml Only


Rest format is Light

In Soap is Heavy due to Tags


Rest is faster than soap

Rest is Not Secure

Soap is Very Secure due to its Envelope

But Rest can be made Secure using Various Token and Authorisation

such Tokens and Authorisation are Web Token or JWT(Json Web Token) Token or OAuth(Original Authorisation) Token


Rest require Low Bandwith

Soap Require high Bandwith


When to use Soap and When to use Rest

--------------------------------------

In Light weight Application use Rest

and Heavy Application use Soap

For Example:

Soap API Used to Send Millions of Email in a Second

SOAP API is used Millions of OTP Verification


JAVA with SOap Good Combination

.Net with Soap is Good Combination

PHP with Soap Bad Combination

PHP With REST Good Combination.



Architecture 



Rest API 

1. Baseurl : Domain Name

2. End Point : url to File or Resource

3. Response should be in Json

4. HTTP METHOD Should be used


API for GET Request:

URL : http://localhost

Baseurl = http://localhost/php_class/rest-api

End Point = users.php

  = product.php

  = orders.php

  

Complete URL:

http://localhost/php_class/rest-api/users.php

http://localhost/php_class/rest-api/product.php

http://localhost/php_class/rest-api/orders.php


Request Sent : POSTMAN 

Request sent : Formdata or Jsondata or Urlencoded Data

Server Response : Json

Request : HTTP METHOD

GET

PUT

POST

DELETE

Rest API Notes