wikipedia-js is a simple client that enables you to query Wikipedia articles in english.
The format of the result is among json
, jsonfm
, wddx
, wddxfm
, xml
, rawfm
.
In the case of html
the result is formatted in basic HTML. You can retrieve either a summary of an article (i.e. before the table of contents) or a full article
Rationale
This project was created because Wikipedia do currently not support a node.js API.
Installation
$ npm install wikipedia-js
Usage
All searches are performed via the single method searchArticle:
var wikipedia = ; var query = "Napoleon Bonaparte"; // if you want to retrieve a full article set summaryOnly to false. // Full article retrieval and parsing is still beta var options = query: query format: "html" summaryOnly: true; wikipedia;
Wiki Markup -> HTML Markup
Below are examples of wiki markup to the left along with the corresponding HTML markup to the right
=title= -> <h1>title</h1>
==title== -> <h2>title</h2>
===title=== -> <h3>title</h3>
====title==== -> <h4>title</h4>
[[French Navy]] -> <a href="http://en.wikipedia.org/wiki/French_Navy">French Navy</a>
[[Louis XVI of France|Louis XVI]] -> <a href="http://en.wikipedia.org/wiki/Louis_XVI">Louis XVI of France</a>
[[Category:1769 births]] -> <span class="category"><a href="http://en.wikipedia.org/wiki/Category:1769_births">1769 births</a></span>
{{Cite book|title=Life of Napoleon Bonaparte|last=Abbott|first=John|isbn=1-4179-7063-4|publisher=Kessinger Publishing|year=2005}} -> <span class="reference" data-type="book " data-first="John" data-last="Abbott" data-year="2005" data-publisher="Kessinger Publishing" data-isbn="1-4179-7063-4">Life of Napoleon Bonaparte</span>
{{Gutenberg|no=3567|name=Memoirs of Napoleon}} -> <a href="http://www.gutenberg.org/ebooks/3567">Memoirs Of Napoleon</a>
Additional features
The following features will be added soon:
- parse metadata
- return other formats i.e.:
yaml
,php
,txt
,dbg
,dump
- improve performance
Acknowledgement
I would like to thank the following people for their contribution to this project:
- torokmark
- richorama
Licence
(The MIT License)
Copyright (c) 2013 Kenshiro <kenshiro@kenshiro.me>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.