Wikipedia is a free, open content online encyclopedia for informative articles on various topics created through the collaborative effort of the community. This project aims to make a RESTful API for these wikipedia articles to be sent from the database to the browser on request.
- Node Js
- Mongoose (ODM)
- Mongo DB
- Robo 3T
- VS Code
- Postman
API stands for Application Programming Interface. An API allows applications to access data and interact with external software components, operating systems, or microservices. To simplify, an API delivers a user response to a system and sends the system's response back to a user.
- REST stands for REpresentational State Transfer.
- It is a software architectural style that defines a set of constraints to be used for creating Web services. Web services that conform to the REST architectural style, called RESTful Web services.
- REST suggests to create an object of the data requested by the client and send the values of the object in response to the user.
- The architectural style of REST helps in leveraging the lesser use of bandwidth to make an application more suitable for the internet.
- Both JSON and XML formats have a proper hierarchical structure of data hence are often used to make APIs.
-
By separating the user interface concerns from the data storage concerns, we improve the portability of the user interface across multiple platforms and improve scalability by simplifying the server components.
Each request from client to server must contain all of the information necessary to understand the request, and cannot take advantage of any stored context on the server.
Cache constraints require that the data within a response to a request be implicitly or explicitly labeled as cacheable or non-cacheable. If a response is cacheable, then a client cache is given the right to reuse that response data for later, equivalent requests.
By applying the software engineering principle of generality to the component interface, the overall system architecture is simplified and the visibility of interactions is improved. In order to obtain this uniform interface, architectural constraints are required that is given by REST. REST is defined by four interface constraints: identification of resources; manipulation of resources through representations; self-descriptive messages; and, hypermedia(ability to open new Web pages by clicking text links on a Web browser) as the engine of application state.
The layered system style allows an architecture to be composed of hierarchical layers by constraining component behavior.
REST allows client functionality to be extended by downloading and executing code in the form of applets or scripts. This simplifies clients by reducing the number of features required to be pre-implemented.
- GET to fetch data
- PUT to replace an existing resource/ data
- PATCH to partially update an existing resource/ data
- POST to create data
- DELETE methods to eliminate it
- Drop a ⭐ on the GitHub repository.
- Download and install a code/ text editor.
- Recommended-
- Download Node Js and npm(Node package manager) (when you download Node, npm also gets installed by default)
- Mongo DB community editition was used for this project. Download Mongo DB community editition
- Robo 3T is a desktop graphical user interface (GUI) for Mongo DB. It can help to skip running all the Mongo DB commands manually every time we want to access the data. Download Robo 3T (optional)
- Clone the repository by running command
- Run command
cd Wiki-RESTful-API
. - Run this command to install all dependencies for the project.
- Run this command on your terminal/ bash to start the Mongo server on port 27017(default).
- Use Postman to test the API and make requests. Download Postman
- Now you are all set to work with the REST API.
git clone https://github.com/Pranav016/Wiki-RESTful-API.git
in your git bash.
npm install
mongod
Use Robo 3T to create a DB with name wikiDB
and store the wikipedia articles.
show dbs
use db <db name>
show collections
<db name> .find()