Skip to content

Commit 2777774

Browse files
committed
feat: 2.20.0
1 parent 73d7d94 commit 2777774

21 files changed

+1324
-3315
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/node_modules
2-
/test
2+
/test
3+
.idea

.prettierrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 4,
4+
"semi": false,
5+
"singleQuote": true
6+
}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Vyacheslav <slava021323@gmail.com>
3+
Copyright (c) 2021-2022 Vyacheslav <slava021323@gmail.com>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 110 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,159 @@
11
# Reverso API
2+
23
[![version](https://badgen.net/npm/v/reverso-api)](https://npmjs.com/package/reverso-api)
34
[![downloads](https://badgen.net/npm/dm/reverso-api)](https://www.npmjs.com/package/reverso-api)
45
[![telegram chat](https://img.shields.io/badge/Ask%20a%20Question-Telegram-blue)](https://t.me/reversoapi)
56

67
[![logotype](/assets/reversoapi-logo.png)](https://npmjs.com/package/reverso-api)
78

8-
This API is not official! It allows you to manipulate with your text in different ways. Almost all the features from the website are supported by this API. Currently supported: context, translation, spell check, synonyms.
9+
Translate, get context examples or synonyms of words - this and much more you can do with your text queries via this API wrapper.
910

1011
## Navigation
11-
- [Installing](#installing)
12-
- [Usage](#usage)
13-
- [Examples](#examples)
14-
- [getContext](#getcontext)
15-
- [getSpellCheck](#getspellcheck)
16-
- [getSynonyms](#getsynonyms)
17-
- [getTranslation](#gettranslation)
18-
- [Languages](#languages)
19-
- [Credits](#credits)
12+
13+
- [Installing](#installing)
14+
- [Usage](#usage)
15+
- [Examples](#examples)
16+
- [getContext](#getcontext)
17+
- [getSpellCheck](#getspellcheck)
18+
- [getSynonyms](#getsynonyms)
19+
- [getTranslation](#gettranslation)
20+
- [Credits](#credits)
2021

2122
## Installing
23+
2224
```bash
2325
$ npm i reverso-api
2426
```
2527

2628
## Usage
29+
2730
```javascript
28-
const Reverso = require('reverso-api');
29-
const reverso = new Reverso();
31+
import { Reverso } from 'reverso-api'
32+
const reverso = new Reverso()
3033
```
34+
3135
Congrats! You can use all the available methods now.\
3236
Let's read through the README and find out how the things work.
3337

3438
You can pass either callback function...
39+
3540
```javascript
36-
reverso.getContext(...params, (response) => {
41+
reverso.getContext(...params, (err, response) => {
3742
...
38-
});
43+
})
3944
```
4045

4146
or use `.then()` function.
4247

4348
```javascript
4449
reverso.getContext(...params).then((response) => {
4550
...
46-
});
51+
})
4752
```
4853

4954
All the examples below are given using callback function.
5055

5156
## Examples
52-
- ### `getContext`
57+
58+
### `getContext`
59+
5360
```javascript
54-
reverso.getContext('meet me half way', 'English', 'Russian', (response) => {
55-
console.log(response);
56-
}).catch((err) => {
57-
console.error(err);
58-
});
61+
reverso.getContext(
62+
'meet me half way',
63+
'english',
64+
'russian',
65+
(err, response) => {
66+
if (err) throw new Error(err.message)
67+
68+
console.log(response)
69+
}
70+
)
5971
```
6072

6173
Response:
74+
6275
```javascript
6376
{
77+
ok: Boolean,
6478
text: String,
65-
from: String,
66-
to: String,
79+
source: String,
80+
target: String,
6781
translation: [String, ...],
6882
examples: [
6983
{
7084
id: Number,
71-
from: String,
72-
to: String
85+
source: String,
86+
target: String
7387
},
7488
...
7589
]
7690
}
7791
```
7892

7993
Error:
94+
8095
```javascript
81-
{ method: String, error: String }
96+
{ ok: Boolean, message: String }
8297
```
8398

84-
- ### `getSpellCheck`
99+
### `getSpellCheck`
100+
85101
```javascript
86-
reverso.getSpellCheck('helo', 'English', (response) => {
87-
console.log(response);
88-
}).catch((err) => {
89-
console.error(err);
90-
});
102+
reverso.getSpellCheck('helo', 'english', (err, response) => {
103+
if (err) throw new Error(err.message)
104+
105+
console.log(response)
106+
})
91107
```
92108

93109
Response:
110+
94111
```javascript
95-
[
96-
{
97-
id: Number,
98-
text: String,
99-
type: String,
100-
explanation: String,
101-
corrected: String,
102-
full_corrected: String
103-
}
104-
]
112+
{
113+
ok: Boolean,
114+
corrections: [
115+
{
116+
id: Number,
117+
text: String,
118+
type: String,
119+
explanation: String,
120+
corrected: String,
121+
suggestions: [
122+
{
123+
text: String,
124+
definition: String,
125+
category: String,
126+
},
127+
...
128+
],
129+
},
130+
]
131+
}
105132
```
106133

107134
Error:
135+
108136
```javascript
109-
{ method: String, error: String }
137+
{ ok: Boolean, message: String }
110138
```
111139

112-
- ### `getSynonyms`
140+
### `getSynonyms`
141+
113142
```javascript
114-
reverso.getSynonyms('dzień dobry', 'Polish', (response) => {
115-
console.log(response);
116-
}).catch((err) => {
117-
console.error(err);
118-
});
143+
reverso.getSynonyms('dzień dobry', 'polish', (err, response) => {
144+
if (err) throw new Error(err.message)
145+
146+
console.log(response)
147+
})
119148
```
120149

121150
Response:
151+
122152
```javascript
123153
{
154+
ok: true,
124155
text: String,
125-
from: String,
156+
source: String,
126157
synonyms: [
127158
{ id: Number, synonym: String },
128159
...
@@ -131,37 +162,45 @@ Response:
131162
```
132163

133164
Error:
165+
134166
```javascript
135-
{ method: String, error: String }
167+
{ ok: Boolean, message: String }
136168
```
137169

138-
- ### `getTranslation`
170+
### `getTranslation`
139171
> ⚠️ **WARNING:** eventually, your server's IP address might get banned by Reverso moderators and you won't receive any data.
172+
140173
```javascript
141-
reverso.getTranslation('how is going?', 'English', 'Chinese', (response) => {
142-
console.log(response);
143-
}).catch((err) => {
144-
console.error(err);
145-
});
174+
reverso.getTranslation(
175+
'how is going?',
176+
'english',
177+
'chinese',
178+
(err, response) => {
179+
if (err) throw new Error(err.message)
180+
181+
console.log(response)
182+
}
183+
)
146184
```
147185

148186
Response:
187+
149188
```javascript
150189
{
151190
text: String,
152-
from: String,
153-
to: String,
154-
translation: [String, ...],
191+
source: String,
192+
target: String,
193+
translations: [String, ...],
155194
context: {
156195
examples: [
157196
{
158-
from: String,
159-
to: String,
160-
phrase_from: String,
161-
phrase_to: String
197+
source: String,
198+
target: String,
199+
phrase_source: String,
200+
phrase_target: String
162201
},
163202
...
164-
],
203+
],
165204
rude: Boolean
166205
}, // or null
167206
detected_language: String,
@@ -170,16 +209,13 @@ Response:
170209
```
171210

172211
Error:
212+
173213
```javascript
174-
{ method: String, error: String }
214+
{ ok: Boolean, message: String }
175215
```
176216

177-
## Languages
178-
`getContext` & `getTranslation`: English, Arabic, German, Spanish, French, Hebrew, Italian, Japanese, Dutch, Polish, Portuguese, Romanian, Russian, Turkish, Chinese. \
179-
`getSynonyms`: English, Russian, German, Spanish, French, Italian, Polish. \
180-
`getSpellCheck`: English, French
181-
182217
## Credits
183-
* All data is provided by [reverso.net](https://reverso.net).
184-
* Author on Telegram [@vychs](https://t.me/vychs).
185-
* Want to talk about the API? Join our [Telegram chat](https://t.me/reversoapi).
218+
219+
- All data is provided by [reverso.net](https://reverso.net).
220+
- Author on Telegram [@vychs](https://t.me/vychs).
221+
- Want to talk about the API? Join our [Telegram chat](https://t.me/reversoapi).

0 commit comments

Comments
 (0)