@divyanshu1610/wiki-quotes

1.0.0 • Public • Published

Wiki-Quotes

Pipeline status

An API for Wikiquote

Installation

With NPM

npm install @divyanshu1610/wiki-quotes --save

Usage

Import library

ES2017 Module style

In Node
import * as Wikiquotes from 'wiki-quotes'

Old style

Old style in Node
const Wikiquotes = require('wiki-quotes')

API

wiki-quotes provides this functions

function getRandomQuote(
  titleList?: [string]
): { title: string, quote: string }

Note: If titleList is not provided a defaultList is used and a random quote by any one of them will be returned otherwise overrided by titleList.

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 }

Examples

Get Random Quote

// 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.'
}

Get Random Quote By Title

// 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.'
}

Powered by Wikidata

Don't forget to add Powered by Wikidata to your project

License

MIT

Package Sidebar

Install

npm i @divyanshu1610/wiki-quotes

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

18 kB

Total Files

5

Last publish

Collaborators

  • divyanshu1610