Skip to content

Pranav016/Wiki-RESTful-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wiki RESTful-API

Wiki-RESTful-API

About -

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.

Tech Stack-

  • Node Js
  • Mongoose (ODM)
  • Mongo DB

Tools used-

  • Robo 3T
  • VS Code
  • Postman

What is an API-

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.

About RESTful APIs-

  • 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.

Guiding Principles of REST

  1. Client–server –
  2. 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.

  3. Stateless –
  4. 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.

  5. Cacheable –
  6. 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.

  7. Uniform interface –
  8. 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.

  9. Layered system –
  10. The layered system style allows an architecture to be composed of hierarchical layers by constraining component behavior.

  11. Code on demand (optional) –
  12. 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.

    Following requests are required to be constructed to make a REST API-

    • 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

    Environment Setup-

    • Drop a ⭐ on the GitHub repository.




    • 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
    git clone https://github.com/Pranav016/Wiki-RESTful-API.git
    

    in your git bash.

    • Run command cd Wiki-RESTful-API.

    • Run this command to install all dependencies for the project.
    npm install
    

    • Run this command on your terminal/ bash to start the Mongo server on port 27017(default).
    mongod
    

    Use Robo 3T to create a DB with name wikiDB and store the wikipedia articles.


    • Now you are all set to work with the REST API.

    Some useful Mongo DB commands if you are using the terminal instead of the GUI-

    show dbs
    use db <db name>
    show collections
    <db name> .find()
    

About

RESTful API for Wikipedia articles.

Topics

Resources

Stars

Watchers

Forks