REST (Representational State Transfer) is a system architecture that defines the set of methods to access the provided web services. The main goal of REST API is to create a system that can be used by different applications.

An API (application programming interface) defines functions and variables. It is used to communicate with a database via php extensions. It is just a collection of protocols and tools for making a software application.

The REST API is created with CRUD (Create, Read, Update, Delete) operations. The REST API is consumed by making an HTTP request (GET, POST, PUT or DELETE) from the client side. The API is implemented in manner to return a response in JSON, XML, or any other format.


class Database{

    private $host = 'localhost';
    private $user = 'root';
    private $password = "password";
    private $database = "demo"; 

    public function getConnection(){	
        $conn = new mysqli($this->host, $this->user, $this->password, $this->database);
            die("Error failed to connect to MySQL: " . $conn->connect_error);
        } else {
            return $conn;