Understand API in less than 10 minutes




API (Application Programming Interface) helps two programs or applications to communicate with each other by providing them with necessary tools and functions.

 

Few Types of API

  • Operating Systems API's
  • Remote API's 
  • Database API's
  • Web API's

 

WEB API

API which can be accessed through HTTP Protocol

WEB API

 

Types of WEB API

  • SOAP (Standard Communication Protocol System)
  • REST (Representational State Transfer)
 

SOAP API

 It exchanges data in form of messages in XML Format

REST API 
  
It is an architectural style for an API that uses HTTP protocol to send and receive data
 
HTTP methods that are majorly used are
  • GET
  • POST
  • PUT
  • PATCH
  • DELETE 
Major Data Format in REST API are
  • application/json
  • application/xml
  • application/x-wbe+xml
  • application/x-www-form-urlencoded
  • multipart/form-data
Endpoints / route
 
In simple words Endpoint in API refers to url/route that is present after base url .

e.g https://google.com/maps

in this example google.com is base url and maps in endpoint

STATUS CODES

  • 1xx : Informational
  • 2xx : Success
  • 3xx : Redirection
  • 4xx :  Client Side Error
  • 5xx : Server Error

 

JSON 

Modern API's (Rest API) send or receive data in JSON Format/Object.

JSON object is similar to Python Dictionary or KEY and VALUE paired ARRAY
 
Format
 
Key/Value paired array : { 'key':value,'key2':value,'key3':value}
 
Python dictionary: {'key':value,'key1':value,'key2':value}
 
JSON Object : {'key':value,'key2':value,'key3':value}

 Example
      
Key/Value paired array : {'name':'john doe',
                                   'username':'johndoe',
                                   'email':'johndoe@email.com'}
 
Python dictionary : {'name':'john doe',
                            'username':'johndoe',
                            'email':'johndoe@email.com'}
 
JSON Object : {'name':'john doe',
                      'username':'johndoe',
                      'email':'johndoe@email.com'}
 

Comments