Access Wikipedia details using Node.js and Wikipedia API

In this tutorial, i will show you how to access Wikipedia details using Node.js and Wikipedia API.

Technology we are going to use for this sample application are :-

  • Node.js :- Node.js® is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
  • Express.js :- Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.
  • request Module :- Request is designed to be the simplest way possible to make http calls. It supports HTTPS and follows redirects by default.
  • Wikipedia API :- The MediaWiki web API is a Web service that provides convenient access to wiki features, data, and meta-data over HTTP.

Introduction :- 

In this tutorial, we will develop Node.js application from scratch using Wikipedia API to access the Wikipedia details.

Setting Up Our Application

To set up our base Node application, we’ll need a few things. We’ll set up our npm packages, node application, configuration files, models, and routes.

Create folder name Node-Wiki [mkdir Node-Wiki] and then go to the folder Node-Wiki and create a file package.json inside the folder.

Packages [package.json]

After creating the file packgae.json.You need to run command npm install
then application structure will be created and all the dependencies installed for your application.

Application Structure

Screen Shot 2015-01-15 at 11.39.59 am

Application Setup [app.js]

Routes routes/index.js,routes/users.js,routes/getDetails.js

We will have the following routes:-

  • Home Page (/) :- Home Page of the application
  • Search Result (/users) :- Give the search result from wikipedia based on limit and title
  • Details Page (/getDetails) :- Show the details of wikipedia page such as image and description

Views views/index.ejs

Here we will define our views :-

Search Result routes/users.js

Show the details of wikipedia page such as image and description by clicking on title(name)routes/getDetails.js


In this article, we learned about how to access wikipedia detail using wikipedia API in a Node.js application. In the process, we also learned how to use request module for http request call and ejs template engine. All of the code from this article is available for download on GitHub.

About Ritesh Kumar

I am Full Stack Developer and Blogger from Bangalore, India.

Leave a Reply

Your email address will not be published. Required fields are marked *