An API for Wikiquote
With NPM
npm install @divyanshu1610/wiki-quotes --save
import * as Wikiquotes from 'wiki-quotes'
const Wikiquotes = require('wiki-quotes')
wiki-quotes
provides this functions
function getRandomQuote(
titleList?: [string]
): { title: string, quote: string }
Note: If
titleList
is not provided adefaultList
is used and a random quote by any one of them will be returned otherwise overrided bytitleList
.
const defaultList = [
'Mahatma Gandhi',
'Albert Einstein',
'Martin Luther King, Jr.',
'Leonardo da Vinci',
'Walt Disney',
'Edgar Allan Poe',
'Sigmund Freud',
'Thomas A. Edison',
'Robin Williams',
'Steve Jobs',
]
function getRandomQuoteByTitle(
titleName: string
): { title: titleName, quote: string }
// returns a promise that resolve with quote and it's person's name as title.
WikiquoteApi.getRandomQuote().then(console.log)
// Output:
{
title: 'Robin Williams',
quote: 'Look! The moon like a testicle hangs low in the sky. This bodes not well.'
}
// returns a promise that resolve with quote and it's person's name as title.
WikiquoteApi.getRandomQuoteByTitle('Mahatma Gandhi').then(console.log)
// Output:
{
title: 'Mahatma Gandhi',
quote: 'Good government is no substitute for self-government.'
}
Don't forget to add Powered by Wikidata
to your project