Skip to content
forked from dijs/wiki

Wikipedia Interface for Node.js

License

Notifications You must be signed in to change notification settings

mYnDstrEAm/wiki

This branch is 89 commits behind dijs/wiki:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

cb90a1e · Feb 10, 2019
Jan 6, 2019
Mar 29, 2018
Jan 8, 2019
Mar 29, 2018
Jan 8, 2019
Mar 29, 2018
Apr 5, 2017
May 21, 2016
Aug 15, 2017
Mar 29, 2018
Jan 7, 2019
Jan 6, 2019
Jan 7, 2019
Sep 2, 2013
Nov 12, 2018
Feb 10, 2019
Jan 8, 2019
Jun 7, 2016

Repository files navigation

NPM Version Build Status Coverage Status paypal

WikiJs is a node.js library which serves as an interface to Wikipedia (or any MediaWiki).

What can it do?

  • Search wiki articles
  • Fetch article content
  • Find all links/images/categories in a article page
  • Get parsed information about articles
  • Find articles by geographical location
  • and much more!

Documentation

https://dijs.github.io/wiki

Install

npm install wikijs

Build yourself

You can run these commands in order to build and test WikiJs:

git clone git@github.com:dijs/wiki.git
cd wiki
npm install
npm run build
npm test

Usage

import wiki from 'wikijs';
// const wiki = require('wikijs').default;

wiki().page('Batman')
	.then(page => page.info('alterEgo'))
	.then(console.log); // Bruce Wayne

Usage with webpack

In order for webpack to build wikijs properly, you must add an option to your webpack configuration file. Documentation

externals: {
  "isomorphic-fetch": "fetch"
}

Usage with other MediaWiki's

You can use the API options configuration:

wiki({
	apiUrl: 'https://awoiaf.westeros.org/api.php',
	origin: null
}).search('Winterfell');

Usage with other languages

You just need to change the API to the proper URL. This is normally just changing the subdomain of wikipedia.

wiki({ apiUrl: 'https://es.wikipedia.org/w/api.php' })
  .page('Cristiano Ronaldo')
  .then(page => page.info())
  .then(console.log);

Read more about Cross Domain Requests here

Usage with custom headers

If you need to pass authentication headers or anything else.

wiki({
	headers: {
		Cookie: 'name=value; name2=value2; name3=value3'
	}
}).search('Winterfell');

Parsing Wiki Infobox Data

The code Wikipedia uses for infobox data is strange and complex. So I have split the parsing code into another library. You can find it here. NPM Version

We not only parse out the information, but also try to transform the data into a convenient structure for data processing.

Contribute!

I always welcome help. Please just stick to the lint rules and write tests with each feature/fix.

Artwork

Thanks to Heather van der Dys for the awesome logo!

About

Wikipedia Interface for Node.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%