{"id":175735,"date":"2024-01-04T19:59:00","date_gmt":"2024-01-04T18:59:00","guid":{"rendered":"https:\/\/liora.io\/en\/?p=175735"},"modified":"2026-02-06T08:39:22","modified_gmt":"2026-02-06T07:39:22","slug":"api-rest-what-is-it-whats-it-for","status":"publish","type":"post","link":"https:\/\/liora.io\/en\/api-rest-what-is-it-whats-it-for","title":{"rendered":"API Rest: What is it? What is it for?"},"content":{"rendered":"<p><strong>Today, web and mobile applications are ubiquitous in our daily lives. Companies are constantly looking for ways to improve the user experience and performance of their applications. This is where REST APIs (API for Application Programming Interface and REST for REpresentational State Transfer) come in.<\/strong><\/p>\nREST APIs are programming interfaces that enable communication between different applications, systems and web services. They have become an essential part of modern application development, and are used in many fields.\n\nWhether you&#8217;re ordering a meal online, exploring the content of your favorite streaming platform or sharing a photo on a social network, you&#8217;re interacting with a REST API.\n\nIn this article, we&#8217;ll take a closer look at what REST APIs are and how they work.\n<h3>API Rest operating principles<\/h3>\nRoy Fielding first defined the principles of REST architecture in 2000. It is based on the following pillars:\n\n<style type=\"text\/css\">\n  .tg  {border-collapse:collapse;border-spacing:0;}<br \/>\n  .tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;<br \/>\n    overflow:hidden;padding:10px 5px;word-break:normal;}<br \/>\n  .tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;<br \/>\n    font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;}<br \/>\n  .tg .tg-jtou{background-color:#c0c0c0;border-color:inherit;color:#ffffff;text-align:center;vertical-align:top}<br \/>\n  .tg .tg-fkky{background-color:#6434fc;border-color:inherit;color:#efefef;font-size:20px;font-weight:bold;text-align:center;<br \/>\n    vertical-align:top}<br \/>\n  .tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top}<br \/>\n<\/style>\n<table style=\"undefined;table-layout: fixed; width: 700px\">\n<colgroup>\n<col style=\"width: 200px\">\n<col style=\"width: 500px\">\n  <\/colgroup>\n<thead>\n<tr>\n<th>Principle<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Client-Server<\/td>\n<td>Client-server architecture, where the client sends a request to the server and waits for its response. The server processes the request and sends the response back to the client.<\/td>\n<\/tr>\n<tr>\n<td>Statelessness<\/td>\n<td>APIs do not store the session state on the server side. Thus, each request is treated independently.<\/td>\n<\/tr>\n<tr>\n<td>Caching<\/td>\n<td>Responses can be cached, eliminating some client-server interactions, improving system scalability and performance.<\/td>\n<\/tr>\n<tr>\n<td>Secure Transport Layer<\/td>\n<td>The secure HTTPS protocol can be used to ensure the security of data transferred between the client and the server.<\/td>\n<\/tr>\n<tr>\n<td>Code on Demand<\/td>\n<td>Servers can temporarily extend or modify a client&#8217;s functionality by transferring executable code to it.<\/td>\n<\/tr>\n<tr>\n<td>Uniform Interface<\/td>\n<td>To achieve application uniformity, the following interface constraints are used:\n<ul>\n \t<li>Resource Identification<\/li>\n \t<li>Resource Manipulation through Representations<\/li>\n \t<li>Self-descriptive Messages<\/li>\n \t<li>Hypertext as the Engine of Application State (HATEOAS)<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<figure>\n\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/liora.io\/app\/uploads\/2023\/05\/image2-1.png\" title=\"\" alt=\"\" loading=\"lazy\"><figcaption><\/figcaption><\/figure>\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex is-content-justification-center\"><div class=\"wp-block-button \"><a class=\"wp-block-button__link wp-element-button \" href=\"\/en\/courses\/data-ai\/data-scientist\">Understanding how REST APIs work<\/a><\/div><\/div>\n\n<h3>What is CRUD?<\/h3>\nThe CRUD principle is a method for describing the basic operations that can be performed on data from a database or API.\n<figure>\n\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/liora.io\/app\/uploads\/2023\/05\/image3-1.png\" title=\"\" alt=\"\" loading=\"lazy\">\n\n<figcaption><\/figcaption><\/figure>\n<strong>CRUD stands for Create, Read, Update &amp; Delete.<\/strong> Let&#8217;s take a look at what each of these terms means:\n<ul>\n \t<li>Create consists in <a href=\"https:\/\/liora.io\/en\/data-sources-understanding-the-definition-and-inner-workings\">adding new data to the data source.<\/a> For example, for a contact management application, create will add a new contact with its information (name, email, telephone, etc.).<\/li>\n \t<li>Read, to <strong>retrieve existing data<\/strong> from the data source. Again in our contact management application, reading will enable the user to consult the details of saved contacts.<\/li>\n \t<li><a href=\"https:\/\/liora.io\/en\/data-owner-everything-you-need-to-know-about-this-job\">Update, to modify existing data<\/a>. Using the same example, the user can modify the telephone number of an existing contact.<\/li>\n \t<li>Delete, to delete existing data. For example, you can delete a contact from your contact list<\/li>\n<\/ul>\n<h3>Anatomy of a query<\/h3>\nA query is composed of the following elements:\n<figure>\n\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/liora.io\/app\/uploads\/2023\/05\/image4-1.png\" title=\"\" alt=\"\" loading=\"lazy\">\n\n<figcaption><\/figcaption><\/figure>\nThe method can be defined as a verb that stipulates what you expect from your request, in line with the <a href=\"https:\/\/liora.io\/en\/crud-definition-and-operation\">CRUD principles. <\/a>The most common methods are :\n<ul>\n \t<li><strong>GET:<\/strong> The server responds to your request by displaying the desired data. This is the Read operation<\/li>\n \t<li><strong>POST:<\/strong> The server creates a new entry in the database, and notifies you of the result. This method executes a Create operation<\/li>\n \t<li><strong>PUT \/ PATCH:<\/strong> These two methods update an entry in the database and notify you of the result. They perform an Update operation<\/li>\n \t<li><strong>DELETE:<\/strong> Deletes an <a href=\"https:\/\/liora.io\/en\/refactoring-databases-and-code-comprehensive-guide-to-the-essentials\">entry from the database<\/a>, and notifies you of the result. This method performs a Delete operation<\/li>\n<\/ul>\nThere are others, but they are much less frequently used: <strong>HEAD, CONNECT, OPTIONS and TRACE.<\/strong>\n\nThe base URL, or request address, is the address you wish to use to <a href=\"https:\/\/liora.io\/en\/api-the-path-to-seamless-integration\">access the API.<\/a>\n\nThe endpoint is the location of the data you wish to interact with\n\nQueries are a set of indications designating what you wish to obtain, in key-value form, linked by &amp;, and preceded by ?\n\nWe&#8217;ve just seen what <strong>makes up a query.<\/strong> Two important elements remain:\n\nThe <strong>headers<\/strong>, which are used to give additional information to the client and server. There are many header parameters, the full list of which is available on the <strong>Mozilla website.<\/strong>\n\nThey are always in key-value form.\n\nThe body of the request is the result returned to you from the server. This result also includes a return code informing you of the success or failure of the request. Codes <strong>2XX indicate success, codes 4XX and 5XX indicate<\/strong> an error (e.g. 400 for an incorrect request, 404 for a resource not found, 501 for an authentication error, etc.).\n\nFinally, codes 3XX indicate a URL redirect.\n<h3>Anatomy of a query<\/h3>\nA query is composed of the following elements:\n<figure>\n\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" src=\"https:\/\/liora.io\/app\/uploads\/2023\/05\/image4-1.png\" title=\"\" alt=\"\" loading=\"lazy\">\n\n<figcaption><\/figcaption><\/figure>\nThe method can be defined as a verb that stipulates what you expect from your request, in line with the <strong>CRUD principles<\/strong> seen above. The most common methods are:\n<ul>\n \t<li><strong>GET:<\/strong> The server responds to your request by displaying the desired data. This is the Read operation<\/li>\n \t<li><strong>POST:<\/strong> The server creates a <a href=\"https:\/\/liora.io\/en\/olap-everything-you-need-to-know-about-this-database-organization\">new entry in the database<\/a>, and notifies you of the result. This method executes a Create operation<\/li>\n \t<li><strong>PUT \/ PATCH:<\/strong> These two methods update an entry in the database and notify you of the result. They perform an Update operation<\/li>\n \t<li><strong>DELETE:<\/strong> <a href=\"https:\/\/liora.io\/en\/50-million-raised-to-develop-the-next-vector-databases\">Deletes an entry from the database<\/a>, and notifies you of the result. This method performs a Delete operation<\/li>\n<\/ul>\nThere are others, but they are much less frequently used: HEAD, CONNECT, OPTIONS and TRACE.\n\nThe base URL, or request address, is the address you wish to use to <a href=\"https:\/\/liora.io\/en\/api-integration-in-python-databases-made-easy\">access the API.<\/a>\n\nThe endpoint is the location of the data you wish to interact with\n\nQueries are a set of indications designating what you wish to obtain, in key-value form, linked by &amp;, and preceded by ?\n\nWe&#8217;ve just seen what makes up a query. Two important elements remain:\n\nThe headers, which are used to give additional information to the client and server. There are many header parameters, the full list of which is available on the <strong>Mozilla website<\/strong>. They are always in key-value form.\n\nThe <strong>body of the request<\/strong> is the result returned to you from the server. This result also includes a return code informing you of the success or failure of the request. Codes 2XX indicate success, codes 4XX and 5XX indicate an error (e.g. 400 for an incorrect request, 404 for a resource not found, 501 for an authentication error, etc.). Finally, codes 3XX indicate a URL redirect.\n<h3>Authentification<\/h3>\nA REST web service must be able to authenticate requests before it can send a response. This authentication verifies the identity of the person making the request.\n\nThe most common authentication methods are as follows:\n<ul>\n \t<li><strong>HTTP basic authentication:<\/strong> The client sends the username and password in the request header, which are then re-encoded in base64 for transmission.<\/li>\n \t<li><strong>API keys:<\/strong> The server assigns you a unique key, usually a string of alphanumeric characters.<\/li>\n \t<li><strong>OAuth:<\/strong> This is the most advanced level of security. The server first requests a password, then an additional token to complete the authentication process.<\/li>\n \t<li>The token can also be checked at regular intervals and have a certain lifetime.<\/li>\n<\/ul>\n<h3>Conclusion<\/h3>\nThis article has given you an insight into <strong>REST APIs<\/strong>, their power and scope. <strong>REST APIs<\/strong> are ubiquitous when it comes to web services and applications. We haven&#8217;t gone into the details of <strong>REST API development<\/strong> here, but the various Liora courses will give you an insight into this aspect.\n\n<a href=\"\/en\/courses\/data-ai\/data-scientist\">\nDiscover our Data Science courses\n<\/a>","protected":false},"excerpt":{"rendered":"<p>Today, web and mobile applications are ubiquitous in our daily lives. Companies are constantly looking for ways to improve the user experience and performance of their applications. This is where REST APIs (API for Application Programming Interface and REST for REpresentational State Transfer) come in. REST APIs are programming interfaces that enable communication between different [&hellip;]<\/p>\n","protected":false},"author":76,"featured_media":175737,"comment_status":"open","ping_status":"open","sticky":false,"template":"elementor_theme","format":"standard","meta":{"_acf_changed":false,"editor_notices":[],"footnotes":""},"categories":[2434],"class_list":["post-175735","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud-dev"],"acf":[],"_links":{"self":[{"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/posts\/175735","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/users\/76"}],"replies":[{"embeddable":true,"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/comments?post=175735"}],"version-history":[{"count":2,"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/posts\/175735\/revisions"}],"predecessor-version":[{"id":206151,"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/posts\/175735\/revisions\/206151"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/media\/175737"}],"wp:attachment":[{"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/media?parent=175735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/liora.io\/en\/wp-json\/wp\/v2\/categories?post=175735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}