RESTful-API

A RESTful-API adhering to REST architecture.

View on GitHub

RESTful-API

A RESTful-API adhering to REST architecture.

Who Invented REST?

REST was defined by Roy Fielding, a computer scientist. He presented the REST principles in his PhD dissertation in 2000.

What is REST (REpresentational State Transfer)?

When a RESTful API is called, the server will transfer to the client a representation of the state of the requested resource.

The representation of the state can be in a JSON format, and probably for most APIs this is indeed the case. (It can also be in XML or HTML format)

What does the server do?

When you, the client, call one of its APIs depends on 2 things that you need to provide to the server:

How does it work?

REST APIs communicate via HTTP requests to perform standard database functions like creating, reading, updating, and deleting records (also known as CRUD) within a resource. For example…

All HTTP methods can be used in API calls. A well-designed REST API is similar to a website running in a web browser with built-in HTTP functionality.

How to run? || Download the zip file to your downloads directory and extract it.

Useful Resources

Here is something to get you started on your RESTful journey!!!

Server Code

//jshint esversion:6

const express = require("express");
const bodyParser = require("body-parser");
const ejs = require("ejs");
const mongoose = require('mongoose');

const app = express();

app.set('view engine', 'ejs');

app.use(bodyParser.urlencoded({
  extended: true
}));
app.use(express.static("public"));

//TODO

app.listen(3000, function() {
  console.log("Server started on port 3000");
});

Re-populate Database

{
    "title" : "API",
    "content" : "API stands for Application Programming Interface. It is a set of subroutine tools & communication protocols used for building software."
}

{
    "title" : "Bootstrap",
    "content" : "This is a framework developed by Twitter that contains pre-made front-end templates for web design"
}

{
    "title" : "DOM",
    "content" : "The Document Object Model is like an API for interacting with our HTML"
}