# wikijs

> Mediawiki interface for Node and Web

Latest version **6.4.1** (published 2023-02-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install wikijs
pnpm add wikijs
yarn add wikijs
bun add wikijs
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 6.4.1 |
| Published | 2023-02-07 |
| First published | 2013-09-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=0.10.4 |
| Dependencies | 3 |
| Unpacked size | 103.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 314 |
| Author | Richard van der Dys |
| Maintainers | rompetoto, dijs |
| Keywords | wiki, wikipedia, interface, search, page, article, node, api, mediawiki |

## Links

- npm: https://www.npmjs.com/package/wikijs
- Repository: https://github.com/dijs/wiki
- Issues: https://github.com/dijs/wiki/issues
- Funding: https://www.buymeacoffee.com/2tmRKi9
- npm.io page: https://npm.io/package/wikijs

## Dependencies (3)

- [hyntax](https://npm.io/package/hyntax.md) ^1.1.9
- [cross-fetch](https://npm.io/package/cross-fetch.md) ^3.0.2
- [infobox-parser](https://npm.io/package/infobox-parser.md) 3.6.2

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 6.4.1 (latest) — 2023-02-07
- 6.4.0 — 2022-11-07
- 6.3.3 — 2021-12-27
- 6.3.2 — 2021-08-16
- 6.3.1 — 2021-08-15
- 6.3.0 — 2021-08-12
- 6.2.3 — 2021-07-24
- 6.2.2 — 2021-07-24
- 6.2.1 — 2021-05-19
- 6.2.0 — 2021-04-24
- 6.1.3 — 2021-04-17
- 6.1.2 — 2021-04-17
- 6.1.1 — 2021-04-14
- 6.1.0 — 2021-04-14
- 6.0.1 — 2019-10-13
- … 79 more at https://npm.io/package/wikijs/versions

## README

<img height="150" src="img/wikijs.png">

[![NPM Version](https://img.shields.io/npm/v/wikijs.svg)](https://www.npmjs.com/package/wikijs)
[![Build Status](https://travis-ci.org/dijs/wiki.svg)](https://travis-ci.org/dijs/wiki)
[![Coverage Status](https://coveralls.io/repos/dijs/wiki/badge.svg)](https://coveralls.io/r/dijs/wiki)

<a href="https://www.buymeacoffee.com/2tmRKi9" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-yellow.png" alt="Buy Me A Coffee" height="41" width="174"></a>

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

```bash
npm install wikijs
```

## Usage

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

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

## Build yourself

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

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

## Usage with webpack

In order for webpack to build wikijs properly, you must add an option to
your webpack configuration file. [Documentation](https://webpack.js.org/configuration/externals/#externals)

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

## Usage with other MediaWiki's

You can use the API options configuration:

```js
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.

```js
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](https://www.mediawiki.org/wiki/API:Main_module)

## Usage with custom headers

If you need to pass authentication headers or anything else.

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

## Chain data requests together for more efficient applications

Query a specific page:

```js
wiki()
	.page('albert einstein')
	.then(page =>
		page
			.chain()
			.summary()
			.image()
			.links()
			.request()
	);
```

Or query many pages at once:

```js
wiki()
	.chain()
	.geosearch(52.52437, 13.41053)
	.summary()
	.image()
	.coordinates()
	.request();
```

## 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](https://github.com/dijs/infobox-parser).
[![NPM Version](https://img.shields.io/npm/v/wikijs.svg)](https://www.npmjs.com/package/infobox-parser)

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](http://heathervanderdys.com/) for the awesome logo!

---
_Source: https://npm.io/package/wikijs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
