![New axobject-query Maintainer Faces Backlash Over Controversial Decision to Support Legacy Node.js Versions](https://cdn.sanity.io/images/cgdhsj6q/production/86e6ebdea652d20da070ebbda20134b839972db7-1024x1024.webp?w=800&fit=max&auto=format)
Security News
New axobject-query Maintainer Faces Backlash Over Controversial Decision to Support Legacy Node.js Versions
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.
wikipedia
Advanced tools
Readme
Wikipedia for node.
Implements legacy wiki endpoints and also the newer REST API.
Try out the new summary()
REST endpoint for a introduction to your page and the main images optimized for browsers and mobile!
You can also now get the events which happened on a particular day using the onThisDay()
api, which supports filtering by event types as well.
Built with latest ES6 and native support for async/await and promises.
Built with TypeScript - exports all the types used.
$ npm install wikipedia
For detailed documentation of methods available on wiki
and page
,
const wiki = require('wikipedia');
(async () => {
try {
const page = await wiki.page('Batman');
console.log(page);
//Response of type @Page object
const summary = await page.summary();
console.log(summary);
//Response of type @wikiSummary - contains the intro and the main image
} catch (error) {
console.log(error);
//=> Typeof wikiError
}
})();
The page method returns a Page class object which has fields like pageid
, title
, parentid
, revisionid
and methods like summary()
, intro()
, images()
, html()
and more.
All the page methods can take a title parameter or a pageId. Read up on the Page documentation here to see a detailed overview of the methods available in page.
You can also call methods like summary()
on the wiki
object directly. Read up here to see when you should use the page
object and when you should call summary()
directly. There's a performance difference! Long story short, use the method directly if you are using only the summary
of the page and are not expecting to use any of the other page
attributes.
const wiki = require('wikipedia');
(async () => {
try {
const summary = await wiki.summary('Batman');
console.log(summary);
//Response of type @wikiSummary - contains the intro and the main image
} catch (error) {
console.log(error);
//=> Typeof wikiError
}
})();
You can now get the events which happened on a particular day using the new onThisDay()
api on the wiki object.
const wiki = require('wikipedia');
(async () => {
try {
const events = await wiki.onThisDay();
const deaths = await wiki.onThisDay({type:'deaths', month:'2', day:'28'});
console.log(events); // returns all the events which happened today
console.log(deaths); // returns all deaths which happened on Feb 28
} catch (error) {
console.log(error);
//=> Typeof wikiError
}
})();
There are other methods like search()
, geoSearch()
, suggest()
, setLang()
which should be called on the wiki object directly. Read up on the wiki documentation to see a complete list of methods available on the wiki default object.
const wiki = require('wikipedia');
(async () => {
try {
const searchResults = await wiki.search('Batma');
console.log(searchResults);
//Response of type @wikiSearchResult - contains results and optionally a suggestion
const newUrl = await wiki.setLang('fr');
console.log(newUrl);
//Returns the api url with language changed - use `languages()` method to see a list of available langs
} catch (error) {
console.log(error);
//=> Typeof wikiError
}
})();
All methods have options you can pass them. You can find them in optionTypes documentation.
All the returned result types are documented as well. You can find them here.
Before opening a pull request please make sure your changes follow the contribution guidelines.
The project would not be the way it is without these rockstars.
Govind S |
Kevin Kee |
Patrick |
0xflotus |
Zac Colley |
FAQs
A JavaScript wrapper for the wikipedia apis
The npm package wikipedia receives a total of 9,644 weekly downloads. As such, wikipedia popularity was classified as popular.
We found that wikipedia demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.
Security News
Results from the 2023 State of JavaScript Survey highlight key trends, including Vite's dominance, rising TypeScript adoption, and the enduring popularity of React. Discover more insights on developer preferences and technology usage.
Security News
The US Justice Department has penalized two consulting firms $11.3 million for failing to meet cybersecurity requirements on federally funded projects, emphasizing strict enforcement to protect sensitive government data.