
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
wikiquote-api
Advanced tools
Small APi for Wikiquote
With Yarn
yarn add wikiquote-api
or with NPM
npm install wikiquote-api --save
<script type="text/javascript" src="./node_modules/babel-polyfill/dist/polyfill.js"></script>
<script type="module" src="./node_modules/wikiquote-api/dist/WikiquoteApi.module.mjs"></script>
import 'babel-polyfill'
import WikiquoteApi from './node_modules/wikiquote-api/dist/WikiquoteApi.module.mjs'
<script type="text/javascript" src="./node_modules/babel-polyfill/dist/polyfill.js"></script>
<script type="text/javascript" src="./node_modules/wikiquote-api/dist/WikiquoteApi.browser.js"></script>
require('babel-polyfill')
const WikiquoteApi = require('wikiquote-api')
WikiquoteApi
provides this functions
async function searchQuotePage(
searchTerm: string,
lang?: string,
searchUrlConfig?: (lang: string) => string
): string[];
async function getQuotePage(
pageTitle: string,
lang?: string,
pageUrlConfig?: (lang: string) => string,
ambiguousPageConfig?: (lang: string) => string
): string;
async function getQuotePageDOM(
pageTitle: string,
lang?: string,
pageUrlConfig?: (lang: string) => string,
ambiguousPageConfig?: (lang: string) => string
): HTMLElement;
async function getFullQuotePage(
searchTerm: string,
lang?: string,
searchUrlConfig?: (lang: string) => string,
pageUrlConfig?: (lang: string) => string,
ambiguousPageConfig?: (lang: string) => string
): Map<string, string>;
async function getFullQuotePageDOM(
searchTerm: string,
lang?: string,
searchUrlConfig?: (lang: string) => string,
pageUrlConfig?: (lang: string) => string,
ambiguousPageConfig?: (lang: string) => string
): Map<string, HTMLElement>;
And this exceptions under the scope exception
WikiquoteApiException
UnsupportedLanguageException
NoSuchPageException
DisambiguationPageException
// returns a promise that resolve with all Spiderman related pages title
WikiquoteApi.searchQuotePage('Spiderman').then(console.log)
/*
Output:
[ 'Spider-Man',
'Spider-Man 3',
'Spider-Man 2',
'Spider-Man: The Animated Series',
'Spider-Man (2002 film)',
'Spider-Man: Homecoming',
'Spider-Man (2000 video game)',
'Spider-Man: Shattered Dimensions',
'Spider-Man 2: Enter Electro',
'Spider-Man: Web of Shadows',
'Spider-Man: Edge of Time',
'Spider-Man 3 (video game)',
'Spider-Man 2 (Video Game)' ]
*/
// returns a promise that resolve with a HTMLElement with the Spider-Man (2002 film)'s HTML content
WikiquoteApi.getQuotePage('Spider-Man (2002 film)').then(console.log)
/*
Output:
<div class="mw-parser-output"><p><i><b><a href="https://en.wikipedia.org/wiki/Spider-Man_(2002_film)" class="extiw" title="w:Spider-Man (2002 film)">Spider-Man</a></b></i> is a 2002 film based on the eponymous <a href="https://en.wikipedia.org/wiki/Marvel_Comics" class="extiw" title="w:Marvel Comics">Marvel comic</a>. It stars <a href="https://en.wikipedia.org/wiki/Tobey_Maguire" class="extiw" title="w:Tobey Maguire">Tobey Maguire</a> and <a href="https://en.wikipedia.org/wiki/Willem_Dafoe" class="extiw" title="w:Willem Dafoe">Willem Dafoe</a> and explains the story ofPeter Parker's struggle to balance between his normal life and his life as Spider Man. This movie is released theaters May 3, 2002 in United States.</p>
...
<li><i>(last words of the movie)</i> Whatever life holds in store for me, I will never forget these words: "With great power comes great responsibility." This is my gift, my curse. Who am I? I'm Spider-Man.</li>
...
*/
HTMLElement
for a given subject// returns a promise that resolve with a Map<page's URL, HTMLElement with the content> of each pages related to Spiderman
WikiquoteApi.getFullQuotePageDOM('Iron Man').then(console.log)
/*
Output:
Map {
'https://en.wikiquote.org/wiki/Iron%20Man%20(2008%20film)' => HTMLDivElement {},
'https://en.wikiquote.org/wiki/Iron%20Man%3A%20Armored%20Adventures' => HTMLDivElement {},
'https://en.wikiquote.org/wiki/Iron%20Man%20(comics)' => HTMLDivElement {},
'https://en.wikiquote.org/wiki/Iron%20Man%203' => HTMLDivElement {},
'https://en.wikiquote.org/wiki/Iron%20Man%202' => HTMLDivElement {},
'https://en.wikiquote.org/wiki/Ted%20Hughes' => HTMLDivElement {},
'https://en.wikiquote.org/wiki/Iron%20Maiden' => HTMLDivElement {} }
*/
Don't forget to add Powered by Wikidata
to your project
After tried severals Javascript API client for Wikidata nothing really suits to my needs or was too big :
So, i created this small API for Wikiquote
FAQs
Small API for Wikiquote
The npm package wikiquote-api receives a total of 5 weekly downloads. As such, wikiquote-api popularity was classified as not popular.
We found that wikiquote-api demonstrated a not healthy version release cadence and project activity because the last version was released 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
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.