Skip to content
A simple API example server for NodeJS using the native HTTP module
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Simple NodeJS API Server

In this example application, we use the native HTTP module for NodeJS to create a simple API server. The server consists of 3 endpoints:

Endpoints are configured to serve HTML content or JSON, that's up to your application's needs.

Tutorial Available

YouTube: NodeJS APIs without Express

NodeJS API without Express

Running the Server

With NodeJS installed, you can started the server by running,

node app.js


npm run start


This simple server can be easily extended. After cloning this repository you can start developing locally.

Locally (without Docker)

  1. Install Nodemon, Nodemon will watch for file changes and restart the NodeJS process. This allows for faster development and testing.
npm install -g nodemon
  1. With Nodemon installed, start the server using Nodemon
nodemon app.js


npm run start:dev

Using Docker

I prefer to use Docker for local development wherever possible. This allows me to have a consistent development environment.

Start Docker Container

With Docker installed, we can start a container using the latest NodeJS Docker image.

docker run -it --rm -p 5000:5000 -v $(pwd):/api -w="/api" node bash

Start the application in development mode using Nodemon inside your Docker Container

npm run start:dev

To stop your running NodeJS API server

ctrl + c

To quit your Docker Container development environment, in your terminal:


This will cleanup any running containers, (note: the Docker image will still exist on your machine)

You can’t perform that action at this time.