{"id":1997,"date":"2022-06-17T19:08:38","date_gmt":"2022-06-17T19:08:38","guid":{"rendered":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/2022\/06\/17\/api-basics-and-architecture\/"},"modified":"2022-06-17T19:08:38","modified_gmt":"2022-06-17T19:08:38","slug":"api-basics-and-architecture","status":"publish","type":"post","link":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/2022\/06\/17\/api-basics-and-architecture\/","title":{"rendered":"API Basics and Architecture"},"content":{"rendered":"<p><html><body><\/p>\n<section class=\"tcb-post-content tcb-shortcode thrv_wrapper\" data-css=\"tve-u-16ec5d248bb\">\n<div class=\"tve_flt tcb-style-wrap\" id=\"tve_flt\">\n<div class=\"tve_shortcode_editor tar-main-content\" data-post-id=\"1997\" id=\"tve_editor\">\n<div class=\"thrv_wrapper tve-toc tve-elem-scroll tve-toc-expandable tcb-local-vars-root\" data-animation=\"slide\" data-animation-speed=\"fast\" data-bullet-style='{\"0\":\"tve-u-62acd13612c461\",\"1\":\"tve-u-62acd13612c478\",\"2\":\"tve-u-62acd13612c491\"}' data-columns=\"1\" data-columns-d=\"1\" data-css=\"tve-u-62acd13612c440\" data-ct=\"toc-60671\" data-ct-name=\"Table of Contents 03\" data-element-name=\"Table of Contents\" data-headers=\"h1,h3,h5\" data-heading-style='{\"0\":\"tve-u-62acd13612ba53\",\"1\":\"tve-u-62acd13612c3f2\",\"2\":\"tve-u-62acd13612c436\"}' data-highlight=\"section\" data-number-style='{\"0\":\"tve-u-62acd13612c4a3\",\"1\":\"tve-u-62acd13612c4c8\",\"2\":\"tve-u-62acd13612c4e1\"}' data-numbering=\"basic\" data-state-default=\"expanded\" data-state-default-m=\"collapsed\" data-transition=\"fade\" style=\"\">\n<div class=\"thrive-colors-palette-config\" style=\"display: none !important\"><\/div>\n<div class=\"tve-toc-divider\" style=\"position: absolute; width: 0; height: 0; overflow: hidden;\">\n<div class=\"thrv_wrapper thrv-divider tve-vert-divider\" data-color-d=\"rgba(0, 0, 0, 0)\" data-css=\"tve-u-62acd13612c4f2\" data-style=\"tve_sep-1\" data-thickness-d=\"1\">\n<hr class=\"tve_sep tve_sep-1\" style=\"\"\/><\/div>\n<\/div>\n<p><svg class=\"toc-icons\" style=\"position: absolute; width: 0; height: 0; overflow: hidden;\" version=\"1.1\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><symbol data-id=\"icon-circle-outlined\" id=\"toc-bullet-0\" viewbox=\"0 0 512 512\"><path d=\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 448c-110.5 0-200-89.5-200-200S145.5 56 256 56s200 89.5 200 200-89.5 200-200 200z\"><\/path><\/symbol><symbol data-id=\"icon-circle-outlined\" id=\"toc-bullet-1\" viewbox=\"0 0 512 512\"><path d=\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 448c-110.5 0-200-89.5-200-200S145.5 56 256 56s200 89.5 200 200-89.5 200-200 200z\"><\/path><\/symbol><symbol data-id=\"icon-circle-outlined\" id=\"toc-bullet-2\" viewbox=\"0 0 512 512\"><path d=\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 448c-110.5 0-200-89.5-200-200S145.5 56 256 56s200 89.5 200 200-89.5 200-200 200z\"><\/path><\/symbol><\/svg><\/p>\n<div class=\"tve-content-box-background\" data-css=\"tve-u-62acd13612c513\" style=\"\"><\/div>\n<div class=\"thrv_wrapper tve-toc-title show-icon tcb-icon-display tve-no-dropzone tve-prevent-content-edit\" data-css=\"tve-u-62acd13612c521\" style=\"\">\n<div class=\"tve-content-box-background\"><\/div>\n<div class=\"tve-cb\" style=\"\">\n<div class=\"tve-toc-title-icon\" data-icon-code=\"icon-arrow-circle-down-solid\" style=\"\"><svg class=\"tcb-icon\" data-id=\"icon-arrow-circle-down-solid\" data-name=\"\" viewbox=\"0 0 512 512\"><path d=\"M504 256c0 137-111 248-248 248S8 393 8 256 119 8 256 8s248 111 248 248zm-143.6-28.9L288 302.6V120c0-13.3-10.7-24-24-24h-16c-13.3 0-24 10.7-24 24v182.6l-72.4-75.5c-9.3-9.7-24.8-9.9-34.3-.4l-10.9 11c-9.4 9.4-9.4 24.6 0 33.9L239 404.3c9.4 9.4 24.6 9.4 33.9 0l132.7-132.7c9.4-9.4 9.4-24.6 0-33.9l-10.9-11c-9.5-9.5-25-9.3-34.3.4z\"><\/path><\/svg><\/div>\n<div class=\"thrv_wrapper thrv_text_element tve_no_icons\">\n<div class=\"tcb-plain-text\" style=\"\">Table of Contents<\/div>\n<\/p><\/div>\n<\/div>\n<\/div>\n<div class=\"tve-cb tve-toc-content tve-prevent-content-edit\">\n<div class=\"thrv_wrapper tve-toc-list tcb-no-delete tcb-no-save tcb-no-clone tve-no-dropzone\" data-css=\"tve-u-62acd13612c546\" style=\"\">\n<div class=\"tve-content-box-background\"><\/div>\n<div class=\"tve-cb\" style=\"\">\n<div class=\"tve_ct_content tve_clearfix\" style=\"\">\n<div class=\"ct_column\">\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-62acd13612c3f2\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939482\" jump-animation=\"smooth\">1. Introduction to API\/Webservices\/Rest API <\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-62acd13612c3f2\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939483\" jump-animation=\"smooth\">2. What you will Learn in this blog?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-62acd13612c3f2\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939484\" jump-animation=\"smooth\">3. Quickly understand \u2018Communication\u2019<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-62acd13612c3f2\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939488\" jump-animation=\"smooth\">4. What is API?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-62acd13612c3f2\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939489\" jump-animation=\"smooth\">5. Practical usage of API<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-62acd13612c3f2\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1642525980189\" jump-animation=\"smooth\">6. A very simple (raw) json<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-62acd13612c3f2\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939491\" jump-animation=\"smooth\">7. Client-Server Architecture<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-62acd13612c3f2\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939492\" jump-animation=\"smooth\">8. Difference between Webservice and API<\/a><\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv-divider tve-vert-divider\" data-color-d=\"rgba(0, 0, 0, 0)\" data-css=\"tve-u-62acd13612c4f2\" data-style=\"tve_sep-1\" data-thickness-d=\"1\">\n<hr class=\"tve_sep tve_sep-1\" style=\"\"\/><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" data-alt-text=\"1. Introduction to API\/Webservices\/Rest API \" id=\"t-1638970939482\"><b>\u00a01.\u00a0<b><b><b><b>Introduction to API\/Webservices\/Rest API<\/b><\/b><\/b>\u00a0<\/b><\/b><\/h3>\n<p>Welcome you all to the brand new \u2018API Testing\u2019 blog series! In this entire series, we would be learning about REST API Automation Testing with Java, Postman. We would be starting with basics and then move to advance topics. So let\u2019s begin!!!\u00a0<\/p>\n<div class=\"code-block code-block-2\" style=\"margin: 8px auto; text-align: center; display: block; clear: both;\">\n<p><!-- horizontal responsive 2 --><br \/>\n<ins class=\"adsbygoogle\" data-ad-client=\"ca-pub-3231318496783163\" data-ad-format=\"auto\" data-ad-slot=\"2788468763\" data-full-width-responsive=\"true\" style=\"display:block\"><\/ins>\n<\/div>\n<h3 class=\"\" data-alt-text=\"2. What you will Learn in this blog?\" id=\"t-1638970939483\"><b>2. <b><b><b><b>What you will Learn in this blog?<\/b><\/b><\/b><\/b><\/b><\/h3>\n<ul class=\"\">\n<li>Quickly understand \u2018Communication\u2019<\/li>\n<li>What is API<\/li>\n<li>Practical usage of API<\/li>\n<li>A very simple (raw) json<\/li>\n<li>Client-Server Architecture<\/li>\n<li>HTTP Protocol<\/li>\n<li>Difference between Webservice and API<\/li>\n<\/ul>\n<h3 class=\"\" data-alt-text=\"3. Quickly understand \u2018Communication\u2019\" id=\"t-1638970939484\"><b>3.\u00a0<b><b><b><b>Quickly understand \u2018Communication\u2019<\/b><\/b><\/b><\/b><\/b><\/h3>\n<p>Before we understand API, let us quickly understand about \u2018Communication\u2019. We know that some <u>medium<\/u> is needed for communication to happen.<\/p>\n<\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-1817323590e\" style=\"\"><span class=\"tve_image_frame\" style=\"\"><img alt=\"\" class=\"tve_image wp-image-1964 tcb-moved-image\" data-css=\"tve-u-1817323607d\" data-height=\"158\" data-id=\"1964\" data-init-height=\"83\" data-init-width=\"300\" data-width=\"571\" decoding=\"async\" height=\"158\" loading=\"lazy\" mt-d=\"-5.9950000000000045\" sizes=\"auto, (max-width: 571px) 100vw, 571px\" src=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-1-300x83.jpg\" srcset=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-1-300x83.jpg 300w, \/blog\/wp-content\/uploads\/2022\/06\/Image-1-768x212.jpg 768w, \/blog\/wp-content\/uploads\/2022\/06\/Image-1.jpg 981w\" style=\"\" title=\"Image 1\" width=\"571\"\/><\/span><\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-18174faaf17\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-1965\" data-css=\"tve-u-18174fada26\" data-height=\"425\" data-id=\"1965\" data-init-height=\"239\" data-init-width=\"300\" data-width=\"533\" decoding=\"async\" height=\"425\" loading=\"lazy\" sizes=\"auto, (max-width: 533px) 100vw, 533px\" src=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-2-300x239.jpg\" srcset=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-2-300x239.jpg 300w, \/blog\/wp-content\/uploads\/2022\/06\/Image-2-768x612.jpg 768w, \/blog\/wp-content\/uploads\/2022\/06\/Image-2.jpg 874w\" style=\"\" title=\"Image 2\" width=\"533\"\/><\/span><\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-18174fb2c52\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-1966 tcb-moved-image\" data-css=\"tve-u-18174fb3baf\" data-height=\"503\" data-id=\"1966\" data-init-height=\"300\" data-init-width=\"207\" data-width=\"347\" decoding=\"async\" height=\"503\" loading=\"lazy\" sizes=\"auto, (max-width: 347px) 100vw, 347px\" src=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-3-207x300.jpg\" srcset=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-3-207x300.jpg 207w, \/blog\/wp-content\/uploads\/2022\/06\/Image-3.jpg 303w\" style=\"\" title=\"Image 3\" width=\"347\"\/><\/span><\/div>\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-62acd13612c553\" style=\"border: 1px solid rgb(0, 0, 0) !important;\">\n<p>Notice above that, though WhatsApp and UPI are different software applications, still they are able to communicate with each other due to the API exposed by UPI.<\/p>\n<p>A software does not need any GUI to communicate with another software. So multiple software exchange data or communicate with each other using machine-readable interfaces, also called as Application programming Interface (API).<\/p>\n<h3 class=\"\" data-alt-text=\"4. What is API?\" data-css=\"tve-u-18174feb7ab\" id=\"t-1638970939488\" style=\"\"><b>4. <b><b><b><b><b>What is API<\/b><\/b><\/b><\/b>?<\/b><\/b><\/h3>\n<p>Now we can understand and define a formal definition of API. API defines a set of rules that enables communication (data transmission) between multiple software. The data exchange between multiple software may or may not involve authentication\/authorization.<\/p>\n<\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-18174fd8be2\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-1967\" data-css=\"tve-u-18174fde10d\" data-height=\"322\" data-id=\"1967\" data-init-height=\"173\" data-init-width=\"300\" data-width=\"559\" decoding=\"async\" height=\"322\" loading=\"lazy\" sizes=\"auto, (max-width: 559px) 100vw, 559px\" src=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-4-300x173.jpg\" srcset=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-4-300x173.jpg 300w, \/blog\/wp-content\/uploads\/2022\/06\/Image-4.jpg 627w\" style=\"\" title=\"Image 4\" width=\"559\"\/><\/span><\/div>\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-62acd13612c553\">\n<p>So, let us say we open a chrome web browser and type <a class=\"tve-froala\" href=\"https:\/\/rahulshettyacademy.com\/\" style=\"outline: none;\">https:\/\/rahulshettyacademy.com\/<\/a> on the browser address bar and Hit Enter. The request would go to an API and the API forwards the request to respective domain \u2018rahulshettyacademy\u2019. The domain (if found), responds back to API and API responds back to web browser. So API acts as an interface between web browser software and website (domain) software. The below diagram explains the same\u00a0<\/p>\n<\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-18174fe5766\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-1970\" data-css=\"tve-u-18174fe708c\" data-height=\"141\" data-id=\"1970\" data-init-height=\"73\" data-init-width=\"300\" data-width=\"579\" decoding=\"async\" height=\"141\" loading=\"lazy\" sizes=\"auto, (max-width: 579px) 100vw, 579px\" src=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-5-300x73.jpg\" srcset=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-5-300x73.jpg 300w, \/blog\/wp-content\/uploads\/2022\/06\/Image-5-1024x248.jpg 1024w, \/blog\/wp-content\/uploads\/2022\/06\/Image-5-768x186.jpg 768w, \/blog\/wp-content\/uploads\/2022\/06\/Image-5.jpg 1113w\" style=\"\" title=\"Image 5\" width=\"579\"\/><\/span><\/div>\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-62acd13612c553\">\n<p><b> <\/b><\/p>\n<h3 class=\"\" data-alt-text=\"5. Practical usage of API\" id=\"t-1638970939489\"><b>5. <b><b><b><b>Practical usage of API<\/b><\/b><\/b><\/b><\/b><\/h3>\n<p>Launch <a class=\"tve-froala\" href=\"https:\/\/www.cleartrip.com\" rel=\"noopener\" style=\"outline: none;\" target=\"_blank\">https:\/\/www.cleartrip.com<\/a> and search for a Delhi-Bangalore flight. We get a lot of search results from different airline companies (Air India, Indigo etc)<\/p>\n<\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-18175005aec\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-1971 tcb-moved-image\" data-css=\"tve-u-18175007f2b\" data-height=\"234\" data-id=\"1971\" data-init-height=\"134\" data-init-width=\"300\" data-width=\"524\" decoding=\"async\" height=\"234\" loading=\"lazy\" sizes=\"auto, (max-width: 524px) 100vw, 524px\" src=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-6-300x134.jpg\" srcset=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-6-300x134.jpg 300w, \/blog\/wp-content\/uploads\/2022\/06\/Image-6.jpg 734w\" style=\"\" title=\"Image 6\" width=\"524\"\/><\/span><\/div>\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-62acd13612c553\">\n<p>Now, \u201ccleartrip\u201d is not an airline company, it is just a 3<sup>rd<\/sup> party software vendor (just like makemytrip, goibibo, yatra etc). Now, how come \u201ccleartrip\u201d company is having the information from different airline companies like Indigo, AirIndia etc? The answer to this question is that, \u201ccleartrip\u201d does NOT have access to the database of airlines (Indigo etc). Instead, airlines expose some of their APIs to 3<sup>rd<\/sup> party websites so that a person can buy tickets on these websites. So, cleartrip is getting the information from Spicejet or Air India through an exposed API.<\/p>\n<\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-1817500e06d\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-1974\" data-css=\"tve-u-1817500f032\" data-height=\"262\" data-id=\"1974\" data-init-height=\"144\" data-init-width=\"300\" data-width=\"546\" decoding=\"async\" height=\"262\" loading=\"lazy\" sizes=\"auto, (max-width: 546px) 100vw, 546px\" src=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-7-300x144.jpg\" srcset=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-7-300x144.jpg 300w, \/blog\/wp-content\/uploads\/2022\/06\/Image-7-768x369.jpg 768w, \/blog\/wp-content\/uploads\/2022\/06\/Image-7.jpg 869w\" style=\"\" title=\"Image 7\" width=\"546\"\/><\/span><\/div>\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-62acd13612c553\">\n<p>So if a user enters source\/destination\/date &amp; searches a flight on 3<sup>rd<\/sup> party vendor (makemytrip.com), the vendor makes an API call to all the airlines and display the results in their respective website browser.<\/p>\n<p>Another practical example would be, when we try to sign-up twitter.<\/p>\n<\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-18175012f4a\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-1975\" data-css=\"tve-u-18175017184\" data-height=\"313\" data-id=\"1975\" data-init-height=\"184\" data-init-width=\"300\" data-width=\"510\" decoding=\"async\" height=\"313\" loading=\"lazy\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" src=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-8-300x184.jpg\" srcset=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-8-300x184.jpg 300w, \/blog\/wp-content\/uploads\/2022\/06\/Image-8.jpg 654w\" style=\"\" title=\"Image 8\" width=\"510\"\/><\/span><\/div>\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-62acd13612c553\">\n<p>Notice above that twitter gives us options to sign-up using gmail or with apple id. So basically, google and apple have exposed their login\/sign-up APIs to twitter. So a user can login twitter using his gmail id (even though both gmail and twitter are different applications).<\/p>\n<h3 class=\"\" data-alt-text=\"6. A very simple (raw) json\" id=\"t-1642525980189\"><b>6.\u00a0<\/b><b><b><b><b>A very simple (raw) json<\/b><\/b><\/b><\/b><\/h3>\n<p>Below is a typical API json <u>request<\/u> (in raw form) that is sent by cleartrip to various airline companies<\/p>\n<\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-1817502bcd6\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-1976\" data-css=\"tve-u-1817502c9d0\" data-height=\"334\" data-id=\"1976\" data-init-height=\"262\" data-init-width=\"300\" data-width=\"383\" decoding=\"async\" height=\"334\" loading=\"lazy\" sizes=\"auto, (max-width: 383px) 100vw, 383px\" src=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-9-300x262.jpg\" srcset=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-9-300x262.jpg 300w, \/blog\/wp-content\/uploads\/2022\/06\/Image-9.jpg 329w\" style=\"\" title=\"Image 9\" width=\"383\"\/><\/span><\/div>\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-62acd13612c553\">\n<p>Below is a typical API json <u>response<\/u> received by cleartrip<\/p>\n<\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-181750327b0\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-1977\" data-css=\"tve-u-181750340cf\" data-height=\"403\" data-id=\"1977\" data-init-height=\"300\" data-init-width=\"295\" data-width=\"396\" decoding=\"async\" height=\"403\" loading=\"lazy\" sizes=\"auto, (max-width: 396px) 100vw, 396px\" src=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-10-295x300.jpg\" srcset=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-10-295x300.jpg 295w, \/blog\/wp-content\/uploads\/2022\/06\/Image-10.jpg 300w\" style=\"\" title=\"Image 10\" width=\"396\"\/><\/span><\/div>\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-62acd13612c553\">\n<p>This is how API helps in communicating between different softwares.x<\/p>\n<h3 class=\"\" data-alt-text=\"7. Client-Server Architecture\" id=\"t-1638970939491\"><b>7. <b><b><b><b>Client-Server Architecture<\/b><\/b><\/b><\/b><\/b><\/h3>\n<p>There are 2 components in client-server architecture.<\/p>\n<ul class=\"\">\n<li>Client is the consumer who wants some information from another software (a client can be a mobile phone, a desktop, laptop etc). Client sends HTTP request to server requesting some information;<\/li>\n<li>Server processes the request and responds back with HTTP response having the desired information \u00a0<\/li>\n<\/ul>\n<\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-1817504ab68\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-1978\" data-css=\"tve-u-1817504bea1\" data-height=\"281\" data-id=\"1978\" data-init-height=\"158\" data-init-width=\"300\" data-width=\"534\" decoding=\"async\" height=\"281\" loading=\"lazy\" sizes=\"auto, (max-width: 534px) 100vw, 534px\" src=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-11-300x158.jpg\" srcset=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-11-300x158.jpg 300w, \/blog\/wp-content\/uploads\/2022\/06\/Image-11.jpg 575w\" style=\"\" title=\"Image 11\" width=\"534\"\/><\/span><\/div>\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-62acd13612c553\">\n<p><span style=\"font-weight: normal;\"><b><u>HTTP Protocol<\/u><\/b><\/span><\/p>\n<p>To setup the communication between client and server, we need a medium. This medium is HTTP protocol. Medium helps both the parties to communicate with each other.<\/p>\n<p>Let us consider a simple analogy to understand this. Let us suppose your native language is Hindi and your friend\u2019s native language is French. You would not understand anything in French and your friend would not understand anything in Hindi. So there should be a common medium, a common language (let\u2019s suppose English) that both, you and your friend would understand. So this is the importance of medium.<\/p>\n<p>See below diagram. The client (frontend) is generally built on HTML, CSS, Javascript languages. The backend is generally designed in different languages php, java, python etc. So, we need a common medium that both, client and server understand. This common medium is HTTP protocol. Client and server can both understand the XML, JSON data formats. HTTP protocol converts the client\/server data into XML, JSON etc. Thus,<\/p>\n<ul class=\"\">\n<li>client sends the request in xml\/json format<\/li>\n<li>server sends back the response in json\/xml format<\/li>\n<\/ul>\n<p>This helps the client-server to communicate with each other using a common data format (XML, JSON).<\/p>\n<\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-181750697f4\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-1979\" data-css=\"tve-u-1817506bc7d\" data-height=\"110\" data-id=\"1979\" data-init-height=\"65\" data-init-width=\"300\" data-width=\"508\" decoding=\"async\" height=\"110\" loading=\"lazy\" sizes=\"auto, (max-width: 508px) 100vw, 508px\" src=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-12-300x65.jpg\" srcset=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-12-300x65.jpg 300w, \/blog\/wp-content\/uploads\/2022\/06\/Image-12-1024x222.jpg 1024w, \/blog\/wp-content\/uploads\/2022\/06\/Image-12-768x166.jpg 768w, \/blog\/wp-content\/uploads\/2022\/06\/Image-12.jpg 1039w\" style=\"\" title=\"Image 12\" width=\"508\"\/><\/span><\/div>\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-62acd13612c553\">\n<h3 class=\"\" data-alt-text=\"8. Difference between Webservice and API\" id=\"t-1638970939492\"><b>8. <b><b><b><b>Difference between Webservice and API<\/b><\/b><\/b><\/b><\/b><\/h3>\n<p>The APIs that interact over HTTP protocol (need internet), we call them as webservices. For example, the cleartrip\/makemytrip is a webservice, because, in order to display the search results, they need to interact over HTTP protocol (need Internet connection) with Indigo\/AirIndia servers<\/p>\n<\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-18175092c42\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-1980\" data-css=\"tve-u-18175094244\" data-height=\"129\" data-id=\"1980\" data-init-height=\"73\" data-init-width=\"300\" data-width=\"529\" decoding=\"async\" height=\"129\" loading=\"lazy\" sizes=\"auto, (max-width: 529px) 100vw, 529px\" src=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-13-300x73.jpg\" srcset=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-13-300x73.jpg 300w, \/blog\/wp-content\/uploads\/2022\/06\/Image-13.jpg 641w\" style=\"\" title=\"Image 13\" width=\"529\"\/><\/span><\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-1817509aa1c\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-1981\" data-css=\"tve-u-1817509bdfc\" data-height=\"236\" data-id=\"1981\" data-init-height=\"134\" data-init-width=\"300\" data-width=\"528\" decoding=\"async\" height=\"236\" loading=\"lazy\" sizes=\"auto, (max-width: 528px) 100vw, 528px\" src=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-14-300x134.jpg\" srcset=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-14-300x134.jpg 300w, \/blog\/wp-content\/uploads\/2022\/06\/Image-14.jpg 734w\" style=\"\" title=\"Image 14\" width=\"528\"\/><\/span><\/div>\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-62acd13612c553\">\n<p>The things that does not need internet or do not interact over HTTP protocol, we call them as API. For example, in order to work with Selenium, we need to integrate our java program with Selenium jar files. To interact with Selenium API jar files, we don\u2019t need internet or http protocol. Similarly, to read data from excel, we can integrate POI library API with our java program and start working without any internet connection.\u00a0<\/p>\n<\/div>\n<div class=\"thrv_wrapper tve_image_caption\" data-css=\"tve-u-181750a0d69\" style=\"\"><span class=\"tve_image_frame\"><img alt=\"\" class=\"tve_image wp-image-1982\" data-css=\"tve-u-181750a1fb5\" data-height=\"117\" data-id=\"1982\" data-init-height=\"67\" data-init-width=\"300\" data-width=\"524\" decoding=\"async\" height=\"117\" loading=\"lazy\" sizes=\"auto, (max-width: 524px) 100vw, 524px\" src=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-15-300x67.jpg\" srcset=\"\/blog\/wp-content\/uploads\/2022\/06\/Image-15-300x67.jpg 300w, \/blog\/wp-content\/uploads\/2022\/06\/Image-15.jpg 620w\" style=\"\" title=\"Image 15\" width=\"524\"\/><\/span><\/div>\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-62acd13612c553\">\n<p>All webservices are APIs but reverse is not true. The weather app on your laptop\/mobile is a webservice (api) that interacts with weather server and provides us real-time weather information.<\/p>\n<p>In the next blog, we would discuss about the HTTP methods (Get, Post, Put, Delete), the components that make an HTTP request and HTTP response and the elements that constitute a REST request (URI etc).<\/p>\n<p>Thank you for reading!\u00a0<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"tcb_flag\" style=\"display: none\"><\/div>\n<\/section>\n<p><\/body><\/html><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Table of Contents 1. Introduction to API\/Webservices\/Rest API 2. What you will Learn in this blog? 3. Quickly understand \u2018Communication\u2019 4. What is API? 5. Practical usage of API 6. A very simple (raw) json 7. Client-Server Architecture 8. Difference between Webservice and API \u00a01.\u00a0Introduction to API\/Webservices\/Rest API\u00a0 Welcome you all to the brand new [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-1997","post","type-post","status-publish","format-standard","hentry","category-api","post-wrapper","thrv_wrapper"],"_links":{"self":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1997","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1997"}],"version-history":[{"count":0,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1997\/revisions"}],"wp:attachment":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1997"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1997"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1997"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}