spanish-dict-api v1.0.2
This package has been deprecated
Switch to spanish-dict-client
spanish-dict-api
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
: Astring
which is the verb to be conjugated.tense
: Astring
which is the tense to be conjugated to. See further down for details.person
: Astring
which is the person to be conjugated to. See further down for details.translateOnError
: Optional Aboolean
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 Tense | Tense (Put this in your program) |
---|---|
Present | presentIndicative |
Preterite | preteritIndicative |
Imperfect | imperfectIndicative |
Conditional | conditionalIndicative |
Subjunctive Tenses
Verb Tense | Tense (Put this in your program) |
---|---|
Present | presentSubjunctive |
Imperfect | imperfectSubjunctive |
Imperfect 2 | imperfectSubjunctive2 |
Future | futureSubjunctive |
Imperative Tenses
Verb Tense | Tense (Put this in your program) |
---|---|
Affirmative | imperative |
Negative | negativeImperative |
Continuous / Progressive Tenses
Verb Tense | Tense (Put this in your program) |
---|---|
Present | presentContinuous |
Preterite | preteritContinuous |
Imperfect | imperfectContinuous |
Conditional | conditionalContinuous |
Future | futureContinuous |
Perfect Tenses
Verb Tense | Tense (Put this in your program) |
---|---|
Present | presentPerfect |
Preterite | preteritPerfect |
Past | pastPerfect |
Conditional | conditionalPerfect |
Future | futurePerfect |
Perfect Subjunctive Tenses
Verb Tense | Tense (Put this in your program) |
---|---|
Past | presentPerfectSubjunctive |
Present | pastPerfectSubjunctive |
Future | futurePerfectSubjunctive |
Misc. Tenses
Verb Tense | Tense (Put this in your program) |
---|---|
Any | any |
Persons
Person | Person code (Put this in your program) |
---|---|
Yo | 0 |
Tú | 1 |
Él/Ella/Usted | 2 |
Nosotros | 3 |
Vosotros | 4 |
Ellos/Ellas/Ustedes | 5 |
Any | 6 |