<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Deepraj Bhatta</title>
    <description>The latest articles on DEV Community by Deepraj Bhatta (@itzdeepraj).</description>
    <link>https://dev.to/itzdeepraj</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F881144%2Fc328435d-7be7-4bca-9ae2-4ec894e2bbed.jpeg</url>
      <title>DEV Community: Deepraj Bhatta</title>
      <link>https://dev.to/itzdeepraj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/itzdeepraj"/>
    <language>en</language>
    <item>
      <title>A tl;dr overview of an API</title>
      <dc:creator>Deepraj Bhatta</dc:creator>
      <pubDate>Wed, 29 Jun 2022 16:34:54 +0000</pubDate>
      <link>https://dev.to/itzdeepraj/a-tldr-overview-of-an-api--26j7</link>
      <guid>https://dev.to/itzdeepraj/a-tldr-overview-of-an-api--26j7</guid>
      <description>&lt;h4&gt;
  
  
  In this article I’m going to discuss the following topics related to an API.
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;What is an API ?&lt;/li&gt;
&lt;li&gt;What is the use of an API ?&lt;/li&gt;
&lt;li&gt;What are the different types of API ?&lt;/li&gt;
&lt;li&gt;What is a Restful API ?&lt;/li&gt;
&lt;li&gt;What are the HTTP verbs related to an API ?&lt;/li&gt;
&lt;li&gt;What are the HTTP status code related to an API ?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What is an API ?
&lt;/h3&gt;

&lt;p&gt;API is more like an agreement or a contract of services between any application with distinct functions. Here, the contract of service referred as an application &lt;strong&gt;INTERFACE&lt;/strong&gt; and application with distinct functions referred as an application &lt;strong&gt;PROGRAMS&lt;/strong&gt;, and that’s  how API stands for &lt;strong&gt;APPLICATION PROGRAMMING INTERFACE&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the use of an API ?
&lt;/h3&gt;

&lt;p&gt;API is mostly used for interaction( by transferring data ) between more than two applications followed by a request-response behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  What are the different types of API ?
&lt;/h3&gt;

&lt;p&gt;There are two ways you can categorized an API.&lt;/p&gt;

&lt;p&gt;1.Based on architecture, for example&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;RPC&lt;/strong&gt; ( Remote Procedure Call ), there are two variation  XML-RPC, JSON-RPC&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;SOAP&lt;/strong&gt; ( Simple Object Access Protocol )&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;REST&lt;/strong&gt; ( Representational  State Transfer )&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;GraphQL&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2.Based on availability, for example&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Open API / Public API&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Partner API&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Internal API / Private API&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Composite API&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In today’s  world most of the APIs are REST Driven or  RESTful ( based on REST  architecture ).&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a Restful API ?
&lt;/h3&gt;

&lt;p&gt;There are six constraints in a REST API or a RESTful API. Any API can be a RESTful  API if it follows those six constrains.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Uniform Interface&lt;/strong&gt; -  An agreement that separates clients from the server. A resource( information that returned by an API ) in the system should have only one logical URI but it should contain links (known as HATEOAS) pointing to relative URIs to fetch related information.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Client-Server&lt;/strong&gt; - Client and the Server must be able to evolve separately without depending upon each other.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Stateless&lt;/strong&gt;- The server will not store anything about the latest request that the client made. It will treat every request as a new one. Here the client is responsible  for managing the state of the application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Layered System&lt;/strong&gt; - A application architecture should be distributed in multiple layers but each layer doesn't need to know anything about any other layer other than the intermediate one.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cacheable&lt;/strong&gt;  - The main function of that constraint is to increase the performance of the application by storing frequently used data either in the client-side or the server side.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Code on demand(optional)&lt;/strong&gt; - Most of the cases its optional. But it works by returning a executable code to support a part of your application.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What are the HTTP verbs related to an API ?
&lt;/h3&gt;

&lt;p&gt;HTTP verbs mainly use to tell the server what to do with the data identified by the url. There are 5 most common HTTP verbs and there uses as follows.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;POST&lt;/strong&gt; - Create new resource ( C )&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GET&lt;/strong&gt; - Read resources ( R )&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PUT&lt;/strong&gt;  -  Update/Replace existing resource  ( E ) &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PATCH&lt;/strong&gt; - Update/Modify existing  resource&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DELETE&lt;/strong&gt; - Delete resources ( D )&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It almost similar to the CRUD functionality with different verbs.&lt;/p&gt;

&lt;h3&gt;
  
  
  What are the HTTP status code related to an API ?
&lt;/h3&gt;

&lt;p&gt;HTTP status code divided into 4 segment and each segment has their own functionality.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2xx series related to Successful Request.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;200 - Successful&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;201 - Resource Created&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;204 - Resource Updated&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3xx series related to Redirection&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;301 - Permanent redirection ( possible to change HTTP verb )&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;307 - Temporary redirection ( can’t change HTTP verb )&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;308 - Permanent redirection ( can’t change HTTP verb )&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4xx series related to Client Error&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;400 - Bad request &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;401 - Wrong credentials ( unauthorized )&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;403 - Lack of  authorization ( forbidden )&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;404 - Resource not exist&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;405 - HTTP verb mismatch&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;422 - Send data in valid&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;5xx series related to Server Error&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;500 - Internal Server error&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;501 - If server don’t know how to handle the request&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;502 - Bad Gateway&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;503 - Service is down for maintenance&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;504 - Gateway timeout&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>api</category>
      <category>javascript</category>
      <category>laravel</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
