top of page

Create API In Nodejs

An API provides interactions between one software and another, but not users.

What is REST?

Application programming interfaces (APIs) are everywhere.

They enable software to communicate with other pieces of software internal or external.

REST is an acronym for Representational State Transfer. It is web standards architecture and HTTP Protocol.

A REST Server simply provides access to resources and REST client accesses and modifies the resources using HTTP protocol.

REST was first introduced by Roy Fielding in 2000.

REST quite common nowadays for online services to have public-facing APIs.

These enable other developers to easily integrate features like social media logins, credit card payments, and behavior tracking.

REST API Operations

HTTP Verbs describe the type of operation:

  • GET: Retrieve a resource

  • POST: Create a resource

  • PUT: Update a resource

  • DELETE: Delete a resource

Advantages of REST APIs

  • Rapid API is a platform for accessing web-based REST APIs. As defined previously, APIs connect services. In addition to services, APIs allow an application to access external data.

  • With the help of REST API, one also will be able to organize complicated applications into a very easy to use resource

  • REST API is cleaner and very easy to explore and discover.

API Code Tree Structure

How to write code


const http = require('http');
const fs = require("fs");
const server = http.createServer(function(req,res){
 if(req.url =="/"){
 res.end("hello from home sides");
 else if(req.url =="/userapi")
 fs.readFile(`${__dirname}/userAPI/userapi.json`,"utf-8", (err,data) =>{ 
server.listen(3000, "",() =>{
 console.log("listening to the port no 3000");


 "name":"rk singh",

 "name":"bk jha",
 "name":"aj kumar",
 "name":"bk garg",

How to run it

PS C:\node js> cd .\httpserver\

PS C:\node js\httpserver> node index.js


Contact us for this nodejs assignment Solutions by Codersarts Specialist who can help you mentor and guide for such nodejs assignments.

If you have project or assignment files, You can send at directly or contact at

Recent Posts

See All


bottom of page