words / powerthesaurus-api

Look up English synonyms, antonyms, etc with powerthesaurus.org
https://npm.im/powerthesaurus-api
MIT License
58 stars 6 forks source link
antonym broader en english narrower powerthesaurus related rhymes similar synonym thesaurus

powerthesaurus-api

Build Coverage Downloads Size

Look up English synonyms, antonyms, and more using powerthesaurus.org: a crowdsourced corpus of nearly 80 million synonyms and 4 million antonyms.

Install

npm:

npm install powerthesaurus-api

Use

var thesaurus = require('powerthesaurus-api')

// Callbacks:
thesaurus('car', function(err, res) {
  if (err) throw err
  console.log(res)
})

// Promises and given a kind:
thesaurus('blue', 'antonyms').then(
  res => {
    console.log(res)
  },
  err => {
    throw err
  }
)

Yields:

[
  {word: 'vehicle', parts: ['noun'], topics: ['carriage', 'transport']},
  {word: 'motorcar', parts: ['noun', 'adjective'], topics: ['vehicle']},
  {word: 'automobile', parts: ['noun', 'adjective'], topics: ['vehicle', 'transport']},
  {word: 'auto', parts: ['noun', 'adjective'], topics: ['transport', 'technology']},
  {word: 'railcar', parts: ['noun'], topics: []},
  // …and 45 more entries
]
[
  {word: 'happy', parts: ['adjective'], topics: ['characteristic', 'decency']},
  {word: 'lighthearted', parts: ['adjective'], topics: ['characteristic', 'happiness']},
  {word: 'joyful', parts: ['adjective'], topics: ['characteristic', 'happiness']},
  {word: 'upbeat', parts: ['adjective'], topics: ['characteristic', 'happiness']},
  {word: 'joyous', parts: ['adjective'], topics: ['characteristic', 'happiness']},
  // …and 45 more entries
]

API

thesaurus(word[, kind][, callback])

Look up words relating to word.

Parameters
Returns

When given a callback, returns nothing and calls callback with either an error or a list of entries. When not given a callback, returns a Promise, that is either resolved with a list of entries or rejected with an error. Up to 50 entries are found by powerthesaurus-api

Entry

Object representing a related word, with the following fields:

License

MIT © Titus Wormer