{"id":340,"date":"2023-01-13T14:45:54","date_gmt":"2023-01-13T14:45:54","guid":{"rendered":"https:\/\/premsvmm.com\/?p=340"},"modified":"2025-05-04T04:33:03","modified_gmt":"2025-05-04T04:33:03","slug":"api-automation","status":"publish","type":"post","link":"https:\/\/premsvmm.com\/index.php\/2023\/01\/13\/api-automation\/","title":{"rendered":"API Automation 101"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">What is APIs?<\/h4>\n\n\n\n<ul>\n<li>In simple terms, when two systems need to communicate with each other, the way how they interact is by using API.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">What is REST API?<\/h4>\n\n\n\n<ul>\n<li>Representational State Transfer API (REST)<\/li>\n\n\n\n<li>REST uses HTTP protocol to transfer data.<\/li>\n\n\n\n<li>RESTful APIs work by sending HTTP requests to a server, which then sends back a response.<\/li>\n\n\n\n<li>Four main HTTP methods to perform CRUD (create,read,update,delete)\n<ul>\n<li><strong>GET<\/strong> requests are used to retrieve data from the server.<\/li>\n\n\n\n<li><strong>POST<\/strong> requests are used to submit new data to the server.<\/li>\n\n\n\n<li><strong>PUT<\/strong> requests are used to update existing data on the server.<\/li>\n\n\n\n<li><strong>DELETE<\/strong> requests are used to delete data from the server.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>The principle of REST \n<ul>\n<li>Statelessness &#8211; each request is unique and doesn&#8217;t require another request context<\/li>\n\n\n\n<li>Client-Server &#8211; request and response architecture using client-server model<\/li>\n\n\n\n<li>Cacheable &#8211; response from the server can be cached on the client side to improve the performance<\/li>\n\n\n\n<li>Layered System &#8211; the architecture is divided into layers, with each layer providing a specific service.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">HTTP verbs!<\/h4>\n\n\n\n<ol>\n<li>GET: Retrieve a representation of a resource&#8217;s contents.<\/li>\n\n\n\n<li>POST: Submit an entity to be processed by the resource identified by the URI.<\/li>\n\n\n\n<li>PUT: Replace all current representations of the target resource with the request payload.<\/li>\n\n\n\n<li>PATCH: Apply partial modifications to a resource.<\/li>\n\n\n\n<li>DELETE: Delete a resource.<\/li>\n\n\n\n<li>HEAD: Retrieve the headers of a resource without the body.<\/li>\n\n\n\n<li>OPTIONS: Retrieve the allowed methods and headers of a resource.<\/li>\n\n\n\n<li>CONNECT: Establish a network connection to a URI using a proxy.<\/li>\n\n\n\n<li>TRACE: Retrieve a diagnostic trace of the request-response chain.<\/li>\n<\/ol>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Rest API Request<\/h4>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"695\" src=\"https:\/\/premsvmm.com\/wp-content\/uploads\/2023\/01\/untitled-1024x695.png\" alt=\"\" class=\"wp-image-373\" style=\"width:628px;height:426px\" srcset=\"https:\/\/premsvmm.com\/wp-content\/uploads\/2023\/01\/untitled-1024x695.png 1024w, https:\/\/premsvmm.com\/wp-content\/uploads\/2023\/01\/untitled-300x204.png 300w, https:\/\/premsvmm.com\/wp-content\/uploads\/2023\/01\/untitled-768x521.png 768w, https:\/\/premsvmm.com\/wp-content\/uploads\/2023\/01\/untitled.png 1046w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Rest API Response<\/h4>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"694\" src=\"https:\/\/premsvmm.com\/wp-content\/uploads\/2023\/01\/untitled-1-1024x694.png\" alt=\"\" class=\"wp-image-375\" style=\"width:645px;height:437px\" srcset=\"https:\/\/premsvmm.com\/wp-content\/uploads\/2023\/01\/untitled-1-1024x694.png 1024w, https:\/\/premsvmm.com\/wp-content\/uploads\/2023\/01\/untitled-1-300x203.png 300w, https:\/\/premsvmm.com\/wp-content\/uploads\/2023\/01\/untitled-1-768x521.png 768w, https:\/\/premsvmm.com\/wp-content\/uploads\/2023\/01\/untitled-1.png 1044w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">What is API automation?<\/h4>\n\n\n\n<ul>\n<li>API(Application Program Interface) automation refers to the process of automating the testing and validation of API.<\/li>\n\n\n\n<li>This can include creating automated test scripts that send various requests to an API and then validating the response received.<\/li>\n\n\n\n<li>API automation helps to validate the API functionality working as expected<\/li>\n\n\n\n<li>Helps to perform regression testing when changes are made to the API.<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Sample Request<\/h4>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;http&quot;,&quot;mime&quot;:&quot;message\/http&quot;,&quot;theme&quot;:&quot;eclipse&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;HTTP&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;http&quot;}\">POST \/api\/v1\/create\/users HTTP\/1.1\nHost: 63896823c5356b25a2ff9df7.mockapi.io\nContent-Type: application\/json\nContent-Length: 91\n\n{\n    &quot;requestId&quot;: &quot;123121&quot;,\n    &quot;items&quot;: &quot;prem&quot;,\n    &quot;count&quot;: &quot;1&quot;,\n    &quot;anyKey&quot;: &quot;kumar&quot;\n}<\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Sample Response<\/h4>\n\n\n\n<p>Response Code : 201 &#8211; Created<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;application\/json&quot;,&quot;theme&quot;:&quot;eclipse&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JSON&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;json&quot;}\">{\n    &quot;createdAt&quot;: &quot;2023-01-15T14:52:35.382Z&quot;,\n    &quot;name&quot;: &quot;Lucille Stoltenberg&quot;,\n    &quot;avatar&quot;: &quot;https:\/\/cloudflare-ipfs.com\/ipfs\/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye\/avatar\/151.jpg&quot;,\n    &quot;id&quot;: &quot;60&quot;,\n    &quot;requestId&quot;: &quot;123121&quot;,\n    &quot;items&quot;: &quot;prem&quot;,\n    &quot;count&quot;: &quot;1&quot;,\n    &quot;anyKey&quot;: &quot;kumar&quot;\n}<\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Tools used to test APIs<\/h4>\n\n\n\n<ul>\n<li><a href=\"https:\/\/www.postman.com\/\" data-type=\"URL\" data-id=\"https:\/\/www.postman.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">PostMan<\/a><\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Libraries used for APIs Automation<\/h4>\n\n\n\n<ul>\n<li><a href=\"https:\/\/mvnrepository.com\/artifact\/io.rest-assured\/rest-assured\" data-type=\"URL\" data-id=\"https:\/\/mvnrepository.com\/artifact\/io.rest-assured\/rest-assured\" target=\"_blank\" rel=\"noreferrer noopener\">Rest Assured<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>What is APIs? What is REST API? HTTP verbs! Rest API Request Rest API Response What is API automation? Sample Request Sample Response Response Code : 201 &#8211; Created Tools used to test APIs Libraries used for APIs Automation<\/p>\n","protected":false},"author":1,"featured_media":523,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"categories":[3],"tags":[12],"_links":{"self":[{"href":"https:\/\/premsvmm.com\/index.php\/wp-json\/wp\/v2\/posts\/340"}],"collection":[{"href":"https:\/\/premsvmm.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/premsvmm.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/premsvmm.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/premsvmm.com\/index.php\/wp-json\/wp\/v2\/comments?post=340"}],"version-history":[{"count":17,"href":"https:\/\/premsvmm.com\/index.php\/wp-json\/wp\/v2\/posts\/340\/revisions"}],"predecessor-version":[{"id":522,"href":"https:\/\/premsvmm.com\/index.php\/wp-json\/wp\/v2\/posts\/340\/revisions\/522"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/premsvmm.com\/index.php\/wp-json\/wp\/v2\/media\/523"}],"wp:attachment":[{"href":"https:\/\/premsvmm.com\/index.php\/wp-json\/wp\/v2\/media?parent=340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/premsvmm.com\/index.php\/wp-json\/wp\/v2\/categories?post=340"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/premsvmm.com\/index.php\/wp-json\/wp\/v2\/tags?post=340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}