Socket
Socket
Sign inDemoInstall

wiki-quotes-api

Package Overview
Dependencies
16
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    wiki-quotes-api

An API for Wikiquote


Version published
Weekly downloads
2
increased by100%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Wiki-Quotes

Pipeline status Published on NPM Coverage

An API for Wikiquote

Installation

With NPM

npm install wiki-quotes-api --save

Usage

Import library

ES2017 Module style
In Node
import * as Wikiquotes from 'wiki-quotes-api'
Old style
Old style in Node
const Wikiquotes = require('wiki-quotes-api')

API

wiki-quotes-api 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,
  language: en
): { 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

Keywords

FAQs

Last updated on 17 Jun 2022

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc