{"id":65825,"date":"2022-07-18T09:01:14","date_gmt":"2022-07-18T09:01:14","guid":{"rendered":"https:\/\/www.cryptocabaret.com\/?p=65825"},"modified":"2022-07-18T09:01:14","modified_gmt":"2022-07-18T09:01:14","slug":"create-a-javascript-api-in-6-minutes","status":"publish","type":"post","link":"https:\/\/www.cryptocabaret.com\/?p=65825","title":{"rendered":"Create a JavaScript API in 6 minutes"},"content":{"rendered":"<p><span class=\"field field--name-title field--type-string field--label-hidden\">Create a JavaScript API in 6 minutes<\/span><br \/>\n<span class=\"field field--name-uid field--type-entity-reference field--label-hidden\"><a title=\"View user profile.\" href=\"https:\/\/opensource.com\/users\/cherrybomb\" class=\"username\">Jessica Cherry<\/a><\/span><br \/>\n<span class=\"field field--name-created field--type-created field--label-hidden\">Mon, 07\/18\/2022 &#8211; 03:00<\/span><\/p>\n<div data-drupal-selector=\"rate-node-70096\" class=\"rate-widget-thumbs-up\" title=\"Register or Login to like.\">\n<div class=\"rate-thumbs-up-btn-up vote-pending\"><a href=\"https:\/\/opensource.com\/user\/register\">Register<\/a> or <a href=\"https:\/\/opensource.com\/user\/login?current=\/rss.xml\">Login<\/a> to like<\/div>\n<div class=\"rate-score\"><a href=\"https:\/\/opensource.com\/user\/register\">Register<\/a> or <a href=\"https:\/\/opensource.com\/user\/login?current=\/rss.xml\">Login<\/a> to like<\/div>\n<\/div>\n<div class=\"clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item\">\n<p>This article demonstrates creating a base API with Express and JavaScript. Express is a NodeJS minimalist web framework. This combination allows for minimal effort to get an API up and running at the speed of light. If you have six minutes of free time, you can get this API working to do something useful.<\/p>\n<\/p>\n<div class=\"embedded-resource-list callout-float-right\">\n<div class=\"field field--name-title field--type-string field--label-hidden field__item\">Programming and development<\/div>\n<div class=\"field field--name-links field--type-link field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/developers.redhat.com\/?intcmp=7016000000127cYAAQ\">Red Hat Developers Blog<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/cheat-sheets?intcmp=7016000000127cYAAQ\">Programming cheat sheets<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/www.redhat.com\/en\/services\/training\/learning-subscription?intcmp=7016000000127cYAAQ\">Try for free: Red Hat Learning Subscription<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/downloads\/bash-programming-guide?intcmp=7016000000127cYAAQ\">eBook: An introduction to programming with Bash<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/developers.redhat.com\/cheat-sheets\/bash-shell-cheat-sheet?intcmp=7016000000127cYAAQ\">Bash shell scripting cheat sheet<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/developers.redhat.com\/e-books\/modernizing-enterprise-java?intcmp=7016000000127cYAAQ\">eBook: Modernizing Enterprise Java<\/a><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<h2>Get started with NodeJS<\/h2>\n<p>What you need for this project is the NodeJS version of your choice. In this example, I use <a href=\"https:\/\/nodejs.org\/en\/download\/\" target=\"_blank\" rel=\"noopener\">NodeJS<\/a> and <a href=\"https:\/\/opensource.com\/article\/19\/8\/getting-started-httpie\" target=\"_blank\" rel=\"noopener\">HTTPie<\/a> for testing, a web browser, and a terminal. Once you have those available, you&#8217;re ready to start. Let&#8217;s get this show on the road!<\/p>\n<p>Set up a project directory and install the tools to get started:<\/p>\n<pre>\n<span class=\"geshifilter\"><code class=\"bash geshifilter-bash\"><span class=\"co4\">$ <\/span><span class=\"kw2\">mkdir<\/span> test-api<\/code><\/span><\/pre>\n<p>The <code>npm init<\/code> command creates the package JSON for our project below. Type <code>npm init<\/code> and press enter several times. The output is shown below:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ npm init<br><br>\nPress ^C at any <span class=\"kw1\">time<\/span> to quit.<br>\npackage name: <span class=\"br0\">(<\/span>test-api<span class=\"br0\">)<\/span><br>\nversion: <span class=\"br0\">(<\/span>1.0.0<span class=\"br0\">)<\/span><br>\ndescription:<br>\nentry point: <span class=\"br0\">(<\/span>index.js<span class=\"br0\">)<\/span><br><span class=\"kw3\">test<\/span> command:<br><span class=\"kw2\">git<\/span> repository:<br>\nkeywords:<br>\nauthor:<br>\nlicense: <span class=\"br0\">(<\/span>ISC<span class=\"br0\">)<\/span><br>\nAbout to <span class=\"kw2\">write<\/span> to <span class=\"sy0\">\/<\/span>Users<span class=\"sy0\">\/<\/span>cherrybomb<span class=\"sy0\">\/<\/span>test-api<span class=\"sy0\">\/<\/span>package.json:<br><br><span class=\"br0\">{<\/span><br>\n\u00a0 <span class=\"st0\">\"name\"<\/span>: <span class=\"st0\">\"test-api\"<\/span>,<br>\n\u00a0 <span class=\"st0\">\"version\"<\/span>: <span class=\"st0\">\"1.0.0\"<\/span>,<br>\n\u00a0 <span class=\"st0\">\"description\"<\/span>: <span class=\"st0\">\"\"<\/span>,<br>\n\u00a0 <span class=\"st0\">\"main\"<\/span>: <span class=\"st0\">\"index.js\"<\/span>,<br>\n\u00a0 <span class=\"st0\">\"scripts\"<\/span>: <span class=\"br0\">{<\/span><br>\n\u00a0 \u00a0 <span class=\"st0\">\"test\"<\/span>: <span class=\"st0\">\"echo <span class=\"es1\">\"<\/span>Error: no test specified<span class=\"es1\">\"<\/span> &amp;&amp; exit 1\"<\/span><br>\n\u00a0 <span class=\"br0\">}<\/span>,<br>\n\u00a0 <span class=\"st0\">\"author\"<\/span>: <span class=\"st0\">\"\"<\/span>,<br>\n\u00a0 <span class=\"st0\">\"license\"<\/span>: <span class=\"st0\">\"ISC\"<\/span><br><span class=\"br0\">}<\/span><br><br><br>\nIs this OK? <span class=\"br0\">(<\/span><span class=\"kw2\">yes<\/span><span class=\"br0\">)<\/span><\/div><\/div><\/pre>\n<p>This utility walks you through creating a <code>package.json<\/code> file. It only covers the most common items, and tries to guess sensible defaults. See <code>npm help init<\/code> for definitive documentation on these fields and exactly what they do.<\/p>\n<p>Use <code>npm install {pkg}<\/code> afterward to install a package and save it as a dependency in the <code>package.json<\/code> file.<\/p>\n<p>Next, install Express using the <a href=\"https:\/\/github.com\/npm\/cli\" target=\"_blank\" rel=\"noopener\"><code>npm<\/code> CLI<\/a>:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ npm <span class=\"kw2\">install<\/span> express Output shown below<br><br>\nnpm WARN cherrybomb No description<br>\nnpm WARN cherrybomb No repository field.<br>\nnpm WARN cherrybomb No license field.<br><br>\n+ express<span class=\"sy0\">@<\/span>4.18.1<br>\nadded <span class=\"nu0\">60<\/span> packages from <span class=\"nu0\">39<\/span> contributors and audited <span class=\"nu0\">136<\/span> packages <span class=\"kw1\">in<\/span> 4.863s<br><br><span class=\"nu0\">16<\/span> packages are looking <span class=\"kw1\">for<\/span> funding<br>\n\u00a0 run <span class=\"sy0\">`<\/span>npm fund<span class=\"sy0\">`<\/span> <span class=\"kw1\">for<\/span> details<br><br>\nfound <span class=\"nu0\">0<\/span> vulnerabilities<\/div><\/div><\/pre>\n<p>Finally, create your source directory and your <code>index.js<\/code> file, which is where the application code lives:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ <span class=\"kw2\">mkdir<\/span> src<br>\n$ <span class=\"kw2\">touch<\/span> src<span class=\"sy0\">\/<\/span>index.js<\/div><\/div><\/pre>\n<p>Time to code!<\/p>\n<h2>Code an API<\/h2>\n<p>For your first act of coding, make a simple &#8220;hello world&#8221; API call. In your <code>index.js<\/code> file, add the code snippet below:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">const express = require<span class=\"br0\">(<\/span><span class=\"st_h\">'express'<\/span><span class=\"br0\">)<\/span><br>\nconst app = express<span class=\"br0\">(<\/span><span class=\"br0\">)<\/span><br>\nconst port = <span class=\"nu0\">5000<\/span><br><br>\napp.get<span class=\"br0\">(<\/span><span class=\"st_h\">'\/'<\/span>, <span class=\"br0\">(<\/span>req, res<span class=\"br0\">)<\/span> =<span class=\"sy0\">&gt;<\/span> <span class=\"br0\">{<\/span><br>\n\u00a0 res.send<span class=\"br0\">(<\/span><span class=\"st_h\">'Hello World!'<\/span><span class=\"br0\">)<\/span><br><span class=\"br0\">}<\/span><span class=\"br0\">)<\/span><br><br>\napp.listen<span class=\"br0\">(<\/span>port, <span class=\"br0\">(<\/span><span class=\"br0\">)<\/span> =<span class=\"sy0\">&gt;<\/span> <span class=\"br0\">{<\/span><br>\n\u00a0 console.log<span class=\"br0\">(<\/span><span class=\"sy0\">`<\/span>Example app listening on port <span class=\"co1\">${port}<\/span><span class=\"sy0\">`<\/span><span class=\"br0\">)<\/span><br><span class=\"br0\">}<\/span><span class=\"br0\">)<\/span><\/div><\/div><\/pre>\n<p>Each of these constant variables is available in the scopes below. Because you&#8217;re not using the following scopes within the code, these constants are used without too much extra thought.<\/p>\n<p>When you call <code>app.get<\/code>, you define the <code>GET{rest article needed}<\/code> endpoint to a forward slash. This also sets the &#8220;hello world&#8221; response.<\/p>\n<p>Finally, in the last section, you will start your app on port 5000. The output on your terminal shows your defined message in a file called <code>console.log<\/code>.<\/p>\n<p>To start your application, run the following command, and see the output as shown:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">$ test-api \u2192 node .<span class=\"sy0\">\/<\/span>src<span class=\"sy0\">\/<\/span>index.js<br>\nExample app listening on port <span class=\"nu0\">5000<\/span><\/div><\/div><\/pre>\n<h2>Test the API<\/h2>\n<p>Now that everything is up and running, make a simple call to ensure your API works. For the first test, just open a browser window and navigate to <code>localhost:5000<\/code>.<\/p>\n<article class=\"align-center media media--type-image media--view-mode-default\">\n<div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/07\/express-api-hello-world.png\" width=\"620\" height=\"522\" alt=\"Express API Hello World\"><\/div>\n<div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><\/p>\n<p>(Jessica Cherry, CC BY-SA 4.0)<\/p>\n<\/div>\n<\/article>\n<p>Next, check out what HTTPie says about the API call:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">HTTP<span class=\"sy0\">\/<\/span><span class=\"nu0\">1.1<\/span> <span class=\"nu0\">200<\/span> OK<br>\nConnection: keep-alive<br>\nContent-Length: <span class=\"nu0\">12<\/span><br>\nContent-Type: text<span class=\"sy0\">\/<\/span>html; <span class=\"re2\">charset<\/span>=utf-<span class=\"nu0\">8<\/span><br>\nDate: Tue, <span class=\"nu0\">21<\/span> Jun <span class=\"nu0\">2022<\/span> <span class=\"nu0\">14<\/span>:<span class=\"nu0\">31<\/span>:06 GMT<br>\nETag: W<span class=\"sy0\">\/<\/span><span class=\"st0\">\"c-Lve95gjOVATpfV8EL5X4nxwjKHE\"<\/span><br>\nKeep-Alive: <span class=\"re2\">timeout<\/span>=<span class=\"nu0\">5<\/span><br>\nX-Powered-By: Express<br><br>\nHello World<span class=\"sy0\">!<\/span><\/div><\/div><\/pre>\n<p>And there you have it! One whole working API call. So what&#8217;s next? Well, you could try some changes to make it more interesting.<\/p>\n<h2>Make your API fun<\/h2>\n<p>The &#8220;hello world&#8221; piece is now done, so it&#8217;s time to do some cool math. You&#8217;ll do some counts instead of just &#8220;hello world.&#8221;<\/p>\n<p>Change your code to look like this:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">const express = require<span class=\"br0\">(<\/span><span class=\"st_h\">'express'<\/span><span class=\"br0\">)<\/span><br>\nconst app = express<span class=\"br0\">(<\/span><span class=\"br0\">)<\/span><br>\nconst port = <span class=\"nu0\">5000<\/span><br><br><span class=\"kw3\">let<\/span> count = <span class=\"nu0\">0<\/span>;<br><br>\napp.get<span class=\"br0\">(<\/span><span class=\"st_h\">'\/api'<\/span>, <span class=\"br0\">(<\/span>req, res<span class=\"br0\">)<\/span> =<span class=\"sy0\">&gt;<\/span> <span class=\"br0\">{<\/span><br>\nres.json<span class=\"br0\">(<\/span><span class=\"br0\">{<\/span>count<span class=\"br0\">}<\/span><span class=\"br0\">)<\/span><br><span class=\"br0\">}<\/span><span class=\"br0\">)<\/span><br><br>\napp.post<span class=\"br0\">(<\/span><span class=\"st_h\">'\/api'<\/span>, <span class=\"br0\">(<\/span>req, res<span class=\"br0\">)<\/span> =<span class=\"sy0\">&gt;<\/span> <span class=\"br0\">{<\/span><br>\n++count;<br>\nres.json<span class=\"br0\">(<\/span><span class=\"br0\">{<\/span>count<span class=\"br0\">}<\/span><span class=\"br0\">)<\/span>;<br><span class=\"br0\">}<\/span><span class=\"br0\">)<\/span>;<br><br>\napp.listen<span class=\"br0\">(<\/span>port, <span class=\"br0\">(<\/span><span class=\"br0\">)<\/span> =<span class=\"sy0\">&gt;<\/span> <span class=\"br0\">{<\/span><br>\nconsole.log<span class=\"br0\">(<\/span><span class=\"sy0\">`<\/span>Example app listening on port <span class=\"co1\">${port}<\/span><span class=\"sy0\">`<\/span><span class=\"br0\">)<\/span><br><span class=\"br0\">}<\/span><span class=\"br0\">)<\/span><\/div><\/div><\/pre>\n<p>Aside from a <code>GET<\/code> command in your code, you now have a <code>POST<\/code> to make some changes to your count. With count defined as <strong>0<\/strong>, the <code>LET<\/code> command allows changes to the <code>COUNT<\/code> variable.<\/p>\n<p>In <code>app.get<\/code>, you get the count, and in <code>app.post<\/code>, you <strong>++count<\/strong>, which counts upwards in increments of 1. When you rerun the <code>GET<\/code>, you receive the new number.<\/p>\n<p>Try out the changes:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">test-api \u2192 node .<span class=\"sy0\">\/<\/span>src<span class=\"sy0\">\/<\/span>index.js<br>\nExample app listening on port <span class=\"nu0\">5000<\/span><\/div><\/div><\/pre>\n<p>Next, use HTTPie to run the <code>GET<\/code> and <code>POST<\/code> operations for a test to confirm it works. Starting with <code>GET<\/code>, you can grab the count:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">test-api \u2192 http GET 127.0.0.1:<span class=\"nu0\">5000<\/span><span class=\"sy0\">\/<\/span>api<br>\nHTTP<span class=\"sy0\">\/<\/span><span class=\"nu0\">1.1<\/span> <span class=\"nu0\">200<\/span> OK<br>\nConnection: keep-alive<br>\nContent-Length: <span class=\"nu0\">11<\/span><br>\nContent-Type: application<span class=\"sy0\">\/<\/span>json; <span class=\"re2\">charset<\/span>=utf-<span class=\"nu0\">8<\/span><br>\nDate: Tue, <span class=\"nu0\">21<\/span> Jun <span class=\"nu0\">2022<\/span> <span class=\"nu0\">15<\/span>:<span class=\"nu0\">23<\/span>:06 GMT<br>\nETag: W<span class=\"sy0\">\/<\/span><span class=\"st0\">\"b-ch7MNww9+xUYoTgutbGr6VU0GaU\"<\/span><br>\nKeep-Alive: <span class=\"re2\">timeout<\/span>=<span class=\"nu0\">5<\/span><br>\nX-Powered-By: Express<br><br><span class=\"br0\">{<\/span><br>\n\u00a0 \u00a0 <span class=\"st0\">\"count\"<\/span>: <span class=\"nu0\">0<\/span><br><span class=\"br0\">}<\/span><\/div><\/div><\/pre>\n<p>Then do a <code>POST<\/code> a couple of times, and watch the changes:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">test-api \u2192 http POST 127.0.0.1:<span class=\"nu0\">5000<\/span><span class=\"sy0\">\/<\/span>api<br>\nHTTP<span class=\"sy0\">\/<\/span><span class=\"nu0\">1.1<\/span> <span class=\"nu0\">200<\/span> OK<br>\nConnection: keep-alive<br>\nContent-Length: <span class=\"nu0\">11<\/span><br>\nContent-Type: application<span class=\"sy0\">\/<\/span>json; <span class=\"re2\">charset<\/span>=utf-<span class=\"nu0\">8<\/span><br>\nDate: Tue, <span class=\"nu0\">21<\/span> Jun <span class=\"nu0\">2022<\/span> <span class=\"nu0\">15<\/span>:<span class=\"nu0\">28<\/span>:<span class=\"nu0\">28<\/span> GMT<br>\nETag: W<span class=\"sy0\">\/<\/span><span class=\"st0\">\"b-qA97yBec1rrOyf2eVsYdWwFPOso\"<\/span><br>\nKeep-Alive: <span class=\"re2\">timeout<\/span>=<span class=\"nu0\">5<\/span><br>\nX-Powered-By: Express<br><br><span class=\"br0\">{<\/span><br>\n\u00a0 \u00a0 <span class=\"st0\">\"count\"<\/span>: <span class=\"nu0\">1<\/span><br><span class=\"br0\">}<\/span><br><br><br>\ntest-api \u2192 http POST 127.0.0.1:<span class=\"nu0\">5000<\/span><span class=\"sy0\">\/<\/span>api<br>\nHTTP<span class=\"sy0\">\/<\/span><span class=\"nu0\">1.1<\/span> <span class=\"nu0\">200<\/span> OK<br>\nConnection: keep-alive<br>\nContent-Length: <span class=\"nu0\">11<\/span><br>\nContent-Type: application<span class=\"sy0\">\/<\/span>json; <span class=\"re2\">charset<\/span>=utf-<span class=\"nu0\">8<\/span><br>\nDate: Tue, <span class=\"nu0\">21<\/span> Jun <span class=\"nu0\">2022<\/span> <span class=\"nu0\">15<\/span>:<span class=\"nu0\">28<\/span>:<span class=\"nu0\">34<\/span> GMT<br>\nETag: W<span class=\"sy0\">\/<\/span><span class=\"st0\">\"b-hRuIfkAGnfwKvpTzajm4bAWdKxE\"<\/span><br>\nKeep-Alive: <span class=\"re2\">timeout<\/span>=<span class=\"nu0\">5<\/span><br>\nX-Powered-By: Express<br><br><span class=\"br0\">{<\/span><br>\n\u00a0 \u00a0 <span class=\"st0\">\"count\"<\/span>: <span class=\"nu0\">2<\/span><br><span class=\"br0\">}<\/span><\/div><\/div><\/pre>\n<p>As you can see, the count goes up! Run one more <code>GET<\/code> operation and see what the output is:<\/p>\n<pre>\n<div class=\"geshifilter\"><div class=\"bash geshifilter-bash\">test-api \u2192 http GET 127.0.0.1:<span class=\"nu0\">5000<\/span><span class=\"sy0\">\/<\/span>api<br>\nHTTP<span class=\"sy0\">\/<\/span><span class=\"nu0\">1.1<\/span> <span class=\"nu0\">200<\/span> OK<br>\nConnection: keep-alive<br>\nContent-Length: <span class=\"nu0\">11<\/span><br>\nContent-Type: application<span class=\"sy0\">\/<\/span>json; <span class=\"re2\">charset<\/span>=utf-<span class=\"nu0\">8<\/span><br>\nDate: Tue, <span class=\"nu0\">21<\/span> Jun <span class=\"nu0\">2022<\/span> <span class=\"nu0\">15<\/span>:<span class=\"nu0\">29<\/span>:<span class=\"nu0\">41<\/span> GMT<br>\nETag: W<span class=\"sy0\">\/<\/span><span class=\"st0\">\"b-hRuIfkAGnfwKvpTzajm4bAWdKxE\"<\/span><br>\nKeep-Alive: <span class=\"re2\">timeout<\/span>=<span class=\"nu0\">5<\/span><br>\nX-Powered-By: Express<br><br><span class=\"br0\">{<\/span><br>\n\u00a0 \u00a0 <span class=\"st0\">\"count\"<\/span>: <span class=\"nu0\">2<\/span><br><span class=\"br0\">}<\/span><\/div><\/div><\/pre>\n<h2>The end and the beginning<\/h2>\n<p>I specialize in infrastructure and <a href=\"https:\/\/opensource.com\/article\/20\/7\/terraform-kubernetes\" target=\"_blank\" rel=\"noopener\">Terraform<\/a>, so this was a really fun way to learn and build something quickly in a language I&#8217;d never used before. JavaScript moves fast, and it can be annoying to see errors that seem obscure or obtuse. I can see where some personal opinions have judged it harshly as a language, but it&#8217;s a strong and useful tool. I hope you enjoyed this walkthrough and learned something new and cool along the way.<\/p>\n<\/div>\n<div class=\"clearfix text-formatted field field--name-field-article-subhead field--type-text-long field--label-hidden field__item\">\n<p>Express yourself by coding a fun API using Express, a NodeJS minimalist web framework.<\/p>\n<\/div>\n<div class=\"field field--name-field-lead-image field--type-entity-reference field--label-hidden field__item\">\n<article class=\"media media--type-image media--view-mode-caption\">\n<div class=\"field field--name-field-media-image field--type-image field--label-hidden field__item\">  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/07\/OSDC_women_computing_2.png\" width=\"520\" height=\"292\" alt=\"Woman sitting in front of her computer\" title=\"Women in computing and open source\"><\/div>\n<div class=\"field field--name-field-caption field--type-text-long field--label-hidden caption field__item\"><span class=\"caption__byline\">Image by: <\/span><\/p>\n<p>Ray Smith<\/p>\n<\/div>\n<\/article>\n<\/div>\n<div class=\"field field--name-field-tags field--type-entity-reference field--label-hidden field__items\">\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/javascript\" hreflang=\"en\">JavaScript<\/a><\/div>\n<div class=\"field__item\"><a href=\"https:\/\/opensource.com\/tags\/programming\" hreflang=\"en\">Programming<\/a><\/div>\n<\/p><\/div>\n<div class=\"hidden field field--name-field-listicle-title field--type-string field--label-hidden field__item\">What to read next<\/div>\n<div class=\"field field--name-field-default-license field--type-list-string field--label-hidden field__item\"><a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\"><br \/>\n        <img decoding=\"async\" alt=\"Creative Commons License\" src=\"https:\/\/www.cryptocabaret.com\/wp-content\/uploads\/2022\/07\/cc-by-sa--18.png\" title=\"This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.\"><\/a>This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.<\/div>\n<section class=\"field field--name-field-comments field--type-comment field--label-hidden comment-wrapper\">\n<div class=\"comments__count\">\n<div class=\"login\"><a href=\"https:\/\/opensource.com\/user\/register?absolute=1\">Register<\/a> or <a href=\"https:\/\/opensource.com\/user\/login?current=\/rss.xml&amp;absolute=1\">Login<\/a> to post a comment.<\/div>\n<\/p><\/div>\n<\/section>\n<p class=\"wpematico_credit\"><small>Powered by <a href=\"http:\/\/www.wpematico.com\" target=\"_blank\" rel=\"noopener\">WPeMatico<\/a><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Create a JavaScript API in 6 minutes Jessica Cherry Mon, 07\/18\/2022 &#8211; 03:00 Register or Login to like Register or Login to like This article demonstrates creating a base API with Express and JavaScript. Express is a NodeJS minimalist web framework. This combination allows for minimal effort to get an API up and running at [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":65826,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[307],"tags":[],"class_list":["post-65825","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-open-source"],"_links":{"self":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts\/65825","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=65825"}],"version-history":[{"count":0,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/posts\/65825\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=\/wp\/v2\/media\/65826"}],"wp:attachment":[{"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=65825"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=65825"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cryptocabaret.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=65825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}