{"componentChunkName":"component---src-templates-blog-post-js","path":"/development/rest-api/","webpackCompilationHash":"f92dbf25810602c1889e","result":{"data":{"site":{"siteMetadata":{"title":"Web Devlog","author":"RossenaHuh","siteUrl":"https://github.com/rossenahuh","comment":{"disqusShortName":"RossenaHuh","utterances":"rossenahuh/my-dev-blog.git"},"sponsor":{"buyMeACoffeeId":"rossena"}}},"markdownRemark":{"id":"b9ca8a16-7573-577c-be7f-aa47f2322009","excerpt":"What is an API?A way to let software components to talk to each other, and it could be in any form.How do APIs relate to Web Services?Web Servieces are just APIs, but in general, not the other way around.REST API = REST web serviceREST API/REST Web Service?An API that follows the…","html":"<h2 id=\"what-is-an-api\"><a href=\"#what-is-an-api\" aria-label=\"what is an api permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is an API?</h2>\n<p>A way to let software components to talk to each other, and it could be in any form.</p>\n<br>\n<p><strong>How do APIs relate to Web Services?</strong></p>\n<ul>\n<li>Web Servieces are just APIs, but in general, not the other way around.</li>\n<li>REST API = REST web service</li>\n</ul>\n<h2 id=\"rest-apirest-web-service\"><a href=\"#rest-apirest-web-service\" aria-label=\"rest apirest web service permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>REST API/REST Web Service?</h2>\n<p>An API that follows the rules of REST specification.</p>\n<ul>\n<li>How software components will talk?</li>\n<li>What kind of messages they will send to each other?</li>\n<li>How requests and responses will be handled?</li>\n</ul>\n<h2 id=\"whats-rest\"><a href=\"#whats-rest\" aria-label=\"whats rest permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What’s REST?</h2>\n<p>REpresentational State Transfer</p>\n<br>\n<p><strong>How does HTTP relate to REST?</strong></p>\n<ul>\n<li>HTTP is an application layer protocol for sending and receiving messages over a network.</li>\n<li>In HTTP, we can use GET method for all sorts of interations.</li>\n<li>REST is a specification that dictates how distributed systems on the web should communicate.</li>\n<li>REST is a certain way to implement and use the HTTP communication.</li>\n</ul>\n<br>\n<p><strong>How does The WEB relate to REST?</strong></p>\n<ul>\n<li>REST is the underlying architecture of the WEB.</li>\n<li>Some developers are breaking the rules.</li>\n<li>It’s not the best architectual style but it’s still better than doing things arbitrarily.</li>\n</ul>\n<h2 id=\"the-most-popular-rest-rules\"><a href=\"#the-most-popular-rest-rules\" aria-label=\"the most popular rest rules permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>The most popular REST rules</h2>\n<ol>\n<li>\n<p>The method information should be expressed in the HTTP verb.</p>\n<div class=\"gatsby-highlight\" data-language=\"http\"><pre class=\"language-http\"><code class=\"language-http\">// Not RESTful\nGET api/users/delete/:userId\n\n// RESTful\nDELETE api/users/:userId</code></pre></div>\n</li>\n<li>\n<p>Scoping information should go in the URI.</p>\n<div class=\"gatsby-highlight\" data-language=\"http\"><pre class=\"language-http\"><code class=\"language-http\">DELETE api/users/:userId &lt;-- URI</code></pre></div>\n</li>\n</ol>\n<h2 id=\"how-a-restful-api-works\"><a href=\"#how-a-restful-api-works\" aria-label=\"how a restful api works permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How a RESTful API works?</h2>\n<ul>\n<li>It uses proper HTTP methods according to the situation (<strong>GET</strong> for getting data, <strong>POST</strong> for creating data)</li>\n<li>Scoping info(and other data) goes in the parameters part of the URI.</li>\n<li>It uses common data formats(most commonly JSON).</li>\n<li>Communication is stateless.</li>\n</ul>\n<br>\n<br>\n<p><em>Source</em></p>\n<p><a href=\"https://www.youtube.com/watch?v=FOZtRzY5x8E\">https://www.youtube.com/watch?v=FOZtRzY5x8E</a></p>\n<br>\n<br>","frontmatter":{"title":"The difference between API and REST API","date":"July 16, 2019"}}},"pageContext":{"isCreatedByStatefulCreatePages":false,"slug":"/development/rest-api/","previous":{"fields":{"slug":"/JavaScript/javascript-concept-12---commonjs/"},"frontmatter":{"title":"JavaScript Concept 12 - Modules in JavaScript (CommonJS, Babel & Webpack)","category":"JavaScript"}},"next":{"fields":{"slug":"/development/csr-and-ssr/"},"frontmatter":{"title":"Sever Side Rendering & Client Side Rendering","category":"Development"}}}}}