{"id":20288016,"url":"https://github.com/dopecodez/wikipedia","last_synced_at":"2025-05-16T05:04:18.161Z","repository":{"id":40698275,"uuid":"296556557","full_name":"dopecodez/Wikipedia","owner":"dopecodez","description":"Wikipedia for node and the browser","archived":false,"fork":false,"pushed_at":"2024-11-25T13:35:57.000Z","size":547,"stargazers_count":89,"open_issues_count":9,"forks_count":20,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-11T07:16:10.341Z","etag":null,"topics":["article","browser","images-optimized","jest","onthisday","test-coverage","today-in-history","typescript","wiki","wiki-engine","wikidata","wikipedia","wikipedia-api"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dopecodez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-18T08:09:35.000Z","updated_at":"2025-04-01T14:09:14.000Z","dependencies_parsed_at":"2024-01-13T14:57:23.103Z","dependency_job_id":"ae3af8e4-e701-4131-8bc1-cf80afaea71a","html_url":"https://github.com/dopecodez/Wikipedia","commit_stats":{"total_commits":170,"total_committers":10,"mean_commits":17.0,"dds":"0.17647058823529416","last_synced_commit":"7d8ae518078c93e98c20542b017445fee63c791f"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dopecodez%2FWikipedia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dopecodez%2FWikipedia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dopecodez%2FWikipedia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dopecodez%2FWikipedia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dopecodez","download_url":"https://codeload.github.com/dopecodez/Wikipedia/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254471061,"owners_count":22076585,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["article","browser","images-optimized","jest","onthisday","test-coverage","today-in-history","typescript","wiki","wiki-engine","wikidata","wikipedia","wikipedia-api"],"created_at":"2024-11-14T14:43:42.487Z","updated_at":"2025-05-16T05:04:18.142Z","avatar_url":"https://github.com/dopecodez.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WIKIPEDIA [![build](https://github.com/dopecodez/Wikipedia/workflows/build/badge.svg)](https://github.com/dopecodez/Wikipedia/actions) [![Test Coverage](https://api.codeclimate.com/v1/badges/a44c826dbef8c7f5ea45/test_coverage)](https://codeclimate.com/github/dopecodez/Wikipedia/test_coverage) [![Contributions](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dopecodez/Wikipedia/issues) [![npm version](https://badge.fury.io/js/wikipedia.svg)](https://badge.fury.io/js/wikipedia)\n\nWikipedia for node. Works in the browser as well.\n\nImplements [legacy](https://www.mediawiki.org/wiki/API:Main_page) wiki endpoints and also the newer \n[REST API](https://en.wikipedia.org/api/rest_v1/#/).\n\nTry out the new [`summary()`][9] REST endpoint for a introduction to your page and the main images optimized for browsers and mobile!\n\nYou can also now get the events which happened on a particular day using the [`onThisDay()`][8] api, which supports filtering by [event types][7] as well.\n\nBuilt with latest ES6 and native support for async/await and promises.\n\nBuilt with TypeScript - exports all the types used.\n\n# INSTALLATION\n\n```\n$ npm install wikipedia\n```\n\n## Highlights\n\n- [What can it do](#what-can-it-do)\n- [Usage](#Usage)\n- [Options](#Options)\n- [Result Types](#result-types)\n- [Contributing](#contributing)\n\nFor detailed documentation of methods available on `wiki` and `page`,\n- [wiki][4]\n- [Page][2]\n\n## What can it do?\n\n- Get a summary for a page which contains the intro and main image optimized for web and mobile with the new wikipedia [REST APIs](https://en.wikipedia.org/api/rest_v1/#/)\n- Fetch article content\n- Find all links/images/categories in a page\n- Gets all the relevant events that happened on a particular day. You can further filter this by [event type][7]\n- Find related articles from the given article\n- Find articles by geographical location\n- Get a wikipedia page as a pdf document\n- Supports switching languages\n- Parses infoboxes using [infobox-parser](https://github.com/dijs/infobox-parser)\n\n## Usage\n\n```js\nconst wiki = require('wikipedia');\n\n(async () =\u003e {\n\ttry {\n\t\tconst page = await wiki.page('Batman');\n\t\tconsole.log(page);\n\t\t//Response of type @Page object\n\t\tconst summary = await page.summary();\n\t\tconsole.log(summary);\n\t\t//Response of type @wikiSummary - contains the intro and the main image\n\t} catch (error) {\n\t\tconsole.log(error);\n\t\t//=\u003e Typeof wikiError\n\t}\n})();\n```\nThe page method returns a [Page][2] class object which has fields like `pageid`, `title`, `parentid`, `revisionid` and methods like `summary()`, `intro()`, `images()`, `html()` and more.\n\nAll the page methods can take a title parameter or a pageId. Read up on the [Page documentation][2] here to see a detailed overview of the methods available in page.\n\nYou can also call methods like `summary()` on the `wiki` object directly. [Read up here][3] 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.\n\n```js\nconst wiki = require('wikipedia');\n\n(async () =\u003e {\n\ttry {\n\t\tconst summary = await wiki.summary('Batman');\n\t\tconsole.log(summary);\n\t\t//Response of type @wikiSummary - contains the intro and the main image\n\t} catch (error) {\n\t\tconsole.log(error);\n\t\t//=\u003e Typeof wikiError\n\t}\n})();\n```\nYou can now get the events which happened on a particular day using the new `onThisDay()` api on the wiki object.\n\n```js\nconst wiki = require('wikipedia');\n\n(async () =\u003e {\n\ttry {\n\t\tconst events = await wiki.onThisDay();\n\t\tconst deaths = await wiki.onThisDay({type:'deaths', month:'2', day:'28'});\n\t\tconsole.log(events); // returns all the events which happened today\n\t\tconsole.log(deaths); // returns all deaths which happened on Feb 28\n\t} catch (error) {\n\t\tconsole.log(error);\n\t\t//=\u003e Typeof wikiError\n\t}\n})();\n```\n\nThere are other methods like `search()`, `geoSearch()`, `suggest()`, `setLang()`, `setUserAgent()` which should be called on the wiki object directly. Read up on the [wiki documentation][4] to see a complete list of methods available on the wiki default object.\n\n```js\nconst wiki = require('wikipedia');\n\n(async () =\u003e {\n\ttry {\n\t\tconst searchResults = await wiki.search('Batma');\n\t\tconsole.log(searchResults);\n\t\t//Response of type @wikiSearchResult - contains results and optionally a suggestion\n\t\tconst newUrl = await wiki.setLang('fr');\n\t\tconsole.log(newUrl);\n\t\t//Returns the api url with language changed - use `languages()` method to see a list of available langs\n\t} catch (error) {\n\t\tconsole.log(error);\n\t\t//=\u003e Typeof wikiError\n\t}\n})();\n```\n\nYou can export types or even specific methods if you are using modern ES6 js or TypeScript.\n```js\nimport wiki from 'wikipedia';\nimport { wikiSummary, summaryError } from 'wikipedia';\nimport { summary } from 'wikipedia';\n\n(async () =\u003e {\n\ttry {\n        let summary: wikiSummary; //sets the object as type wikiSummary\n\t\tsummary = await wiki.summary('Batman');\n\t\tconsole.log(summary);\n        let summary2 = await summary('Batman');//using summary directly\n\t} catch (error) {\n\t\tconsole.log(error);\n\t\t//=\u003e Typeof summaryError, helpful in case you want to handle this error separately\n\t}\n})();\n```\n\n## Options\n\nAll methods have options you can pass them. You can find them in [optionTypes documentation][5].\n\n## Result Types\n\nAll the returned result types are documented as well. You can find them [here][6].\n\n## Contributing\n\nBefore opening a pull request please make sure your changes follow the [contribution guidelines][1].\n\n\n## Contributors\n\nThe project would not be the way it is without these rockstars.\n\n\u003c!-- readme: contributors -start --\u003e\n\u003ctable\u003e\n\u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\n        \u003ca href=\"https://github.com/dopecodez\"\u003e\n            \u003cimg src=\"https://avatars.githubusercontent.com/u/34269105?v=4\" width=\"100;\" alt=\"dopecodez\"/\u003e\n            \u003cbr /\u003e\n            \u003csub\u003e\u003cb\u003eGovind S\u003c/b\u003e\u003c/sub\u003e\n        \u003c/a\u003e\n    \u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\n        \u003ca href=\"https://github.com/friendofdog\"\u003e\n            \u003cimg src=\"https://avatars.githubusercontent.com/u/8337121?v=4\" width=\"100;\" alt=\"friendofdog\"/\u003e\n            \u003cbr /\u003e\n            \u003csub\u003e\u003cb\u003eKevin Kee\u003c/b\u003e\u003c/sub\u003e\n        \u003c/a\u003e\n    \u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\n        \u003ca href=\"https://github.com/bumbummen99\"\u003e\n            \u003cimg src=\"https://avatars.githubusercontent.com/u/4533331?v=4\" width=\"100;\" alt=\"bumbummen99\"/\u003e\n            \u003cbr /\u003e\n            \u003csub\u003e\u003cb\u003ePatrick\u003c/b\u003e\u003c/sub\u003e\n        \u003c/a\u003e\n    \u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\n        \u003ca href=\"https://github.com/gtibrett\"\u003e\n            \u003cimg src=\"https://avatars.githubusercontent.com/u/47423?v=4\" width=\"100;\" alt=\"gtibrett\"/\u003e\n            \u003cbr /\u003e\n            \u003csub\u003e\u003cb\u003eBrett\u003c/b\u003e\u003c/sub\u003e\n        \u003c/a\u003e\n    \u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\n        \u003ca href=\"https://github.com/0xflotus\"\u003e\n            \u003cimg src=\"https://avatars.githubusercontent.com/u/26602940?v=4\" width=\"100;\" alt=\"0xflotus\"/\u003e\n            \u003cbr /\u003e\n            \u003csub\u003e\u003cb\u003e0xflotus\u003c/b\u003e\u003c/sub\u003e\n        \u003c/a\u003e\n    \u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\n        \u003ca href=\"https://github.com/Greeshmareji\"\u003e\n            \u003cimg src=\"https://avatars.githubusercontent.com/u/57181018?v=4\" width=\"100;\" alt=\"Greeshmareji\"/\u003e\n            \u003cbr /\u003e\n            \u003csub\u003e\u003cb\u003eGreeshma R\u003c/b\u003e\u003c/sub\u003e\n        \u003c/a\u003e\n    \u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\n        \u003ca href=\"https://github.com/Jman1868\"\u003e\n            \u003cimg src=\"https://avatars.githubusercontent.com/u/43161576?v=4\" width=\"100;\" alt=\"Jman1868\"/\u003e\n            \u003cbr /\u003e\n            \u003csub\u003e\u003cb\u003eJamal Ahmed\u003c/b\u003e\u003c/sub\u003e\n        \u003c/a\u003e\n    \u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\n        \u003ca href=\"https://github.com/zoetrope69\"\u003e\n            \u003cimg src=\"https://avatars.githubusercontent.com/u/2591901?v=4\" width=\"100;\" alt=\"zoetrope69\"/\u003e\n            \u003cbr /\u003e\n            \u003csub\u003e\u003cb\u003eZ\u003c/b\u003e\u003c/sub\u003e\n        \u003c/a\u003e\n    \u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\n        \u003ca href=\"https://github.com/bigmistqke\"\u003e\n            \u003cimg src=\"https://avatars.githubusercontent.com/u/10504064?v=4\" width=\"100;\" alt=\"bigmistqke\"/\u003e\n            \u003cbr /\u003e\n            \u003csub\u003e\u003cb\u003eBigmistqke\u003c/b\u003e\u003c/sub\u003e\n        \u003c/a\u003e\n    \u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\n        \u003ca href=\"https://github.com/yg-i\"\u003e\n            \u003cimg src=\"https://avatars.githubusercontent.com/u/148152939?v=4\" width=\"100;\" alt=\"yg-i\"/\u003e\n            \u003cbr /\u003e\n            \u003csub\u003e\u003cb\u003eNull\u003c/b\u003e\u003c/sub\u003e\n        \u003c/a\u003e\n    \u003c/td\u003e\u003c/tr\u003e\n\u003c/table\u003e\n\u003c!-- readme: contributors -end --\u003e\n\n[1]: https://github.com/dopecodez/wikipedia/blob/master/CONTRIBUTING.md\n[2]: https://github.com/dopecodez/wikipedia/blob/master/docs/PAGE.md\n[3]: https://github.com/dopecodez/wikipedia/blob/master/docs/USAGE.md#when-to-use-page\n[4]: https://github.com/dopecodez/wikipedia/blob/master/docs/wiki.md\n[5]: https://github.com/dopecodez/wikipedia/blob/master/docs/optionTypes.md\n[6]: https://github.com/dopecodez/wikipedia/blob/master/docs/resultTypes.md\n[7]: https://github.com/dopecodez/wikipedia/blob/master/docs/optionTypes.md#eventOptions\n[8]: https://github.com/dopecodez/wikipedia/blob/master/docs/wiki.md#onThisDay\n[9]: https://github.com/dopecodez/wikipedia/blob/master/docs/PAGE.md#summary\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdopecodez%2Fwikipedia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdopecodez%2Fwikipedia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdopecodez%2Fwikipedia/lists"}