1.0.2 • Published 5 years ago

spanish-dict-api v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
5 years ago

This package has been deprecated

Switch to spanish-dict-client

spanish-dict-api

npm version

Disclaimer

This is not an actual API, it is sort of like one. This package is not endorsed by, or correlated to, SpanishDict or Curiosity Media Inc., it simply scrapes www.spanishdict.com and returns data from the site.

Info

This package currently can only translate and conjugate. I will expand the project if there is enough interest.

Installation

Paste this into your command line: npm install spanish-dict-api

Put this at the top of your JavaScript file: const dict = require('spanish-dict-api');

Functions

Translate .translate(<word>)

The translate function translates a verb from either Spanish to English, or English to Spanish.

The function takes in one parameter, the word. This parameter can either be a string or an object with the key of word. It returns a promise which if resolved, returns an array with the translations, or if rejected returns an error.

Example:

dict.translate('ser')
  .then(console.log)
  .catch(console.log);

//Outputs: [ 'to be' ]  

Conjugate .conjugate(<options>)

The conjugate function conjugates a Spanish verb, even if the verb is already conjugated.

The function takes in one object, options. Here are the potential keys that can be used:

  • word: A string which is the verb to be conjugated.
  • tense: A string which is the tense to be conjugated to. See further down for details.
  • person: A string which is the person to be conjugated to. See further down for details.
  • translateOnError: Optional A boolean which, if true, translates the word instead of conjugating it if the word is not a Spanish verb.

Example:

var options = {
  word: 'hacer',
  tense: 'preteritIndicative',
  person: '4',
  translateOnError: true
};

dict.conjugate(options)
  .then(console.log)
  .catch(console.log);

//Outputs: [ 'hicisteis' ]

Tenses

Indicative Tenses

Verb TenseTense (Put this in your program)
PresentpresentIndicative
PreteritepreteritIndicative
ImperfectimperfectIndicative
ConditionalconditionalIndicative

Subjunctive Tenses

Verb TenseTense (Put this in your program)
PresentpresentSubjunctive
ImperfectimperfectSubjunctive
Imperfect 2imperfectSubjunctive2
FuturefutureSubjunctive

Imperative Tenses

Verb TenseTense (Put this in your program)
Affirmativeimperative
NegativenegativeImperative

Continuous / Progressive Tenses

Verb TenseTense (Put this in your program)
PresentpresentContinuous
PreteritepreteritContinuous
ImperfectimperfectContinuous
ConditionalconditionalContinuous
FuturefutureContinuous

Perfect Tenses

Verb TenseTense (Put this in your program)
PresentpresentPerfect
PreteritepreteritPerfect
PastpastPerfect
ConditionalconditionalPerfect
FuturefuturePerfect

Perfect Subjunctive Tenses

Verb TenseTense (Put this in your program)
PastpresentPerfectSubjunctive
PresentpastPerfectSubjunctive
FuturefuturePerfectSubjunctive

Misc. Tenses

Verb TenseTense (Put this in your program)
Anyany

Persons

PersonPerson code (Put this in your program)
Yo0
1
Él/Ella/Usted2
Nosotros3
Vosotros4
Ellos/Ellas/Ustedes5
Any6
1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago