@sharpapi/sharpapi-node-proofread 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +278 -0
- package/package.json +40 -0
- package/src/SharpApiProofreadService.js +20 -0
- package/src/index.js +6 -0
package/README.md
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
# Proofread & Grammar Checker API for Node.js
|
|
4
|
+
|
|
5
|
+
## ✍️ Fix grammar and spelling errors with AI — powered by SharpAPI.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@sharpapi/sharpapi-node-proofread)
|
|
8
|
+
[](https://github.com/sharpapi/sharpapi-node-client/blob/master/LICENSE.md)
|
|
9
|
+
|
|
10
|
+
**SharpAPI Proofread & Grammar Checker** uses advanced AI to detect and correct grammar, spelling, punctuation, and style errors. Perfect for content creation, document editing, and quality assurance.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 📋 Table of Contents
|
|
15
|
+
|
|
16
|
+
1. [Requirements](#requirements)
|
|
17
|
+
2. [Installation](#installation)
|
|
18
|
+
3. [Usage](#usage)
|
|
19
|
+
4. [API Documentation](#api-documentation)
|
|
20
|
+
5. [Examples](#examples)
|
|
21
|
+
6. [License](#license)
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Requirements
|
|
26
|
+
|
|
27
|
+
- Node.js >= 16.x
|
|
28
|
+
- npm or yarn
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
### Step 1. Install the package via npm:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install @sharpapi/sharpapi-node-proofread
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Step 2. Get your API key
|
|
41
|
+
|
|
42
|
+
Visit [SharpAPI.com](https://sharpapi.com/) to get your API key.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
```javascript
|
|
49
|
+
const { SharpApiProofreadService } = require('@sharpapi/sharpapi-node-proofread');
|
|
50
|
+
|
|
51
|
+
const apiKey = process.env.SHARP_API_KEY; // Store your API key in environment variables
|
|
52
|
+
const service = new SharpApiProofreadService(apiKey);
|
|
53
|
+
|
|
54
|
+
const text = `
|
|
55
|
+
This is a sentance with some erors that need to be fixed.
|
|
56
|
+
Their are several gramatical mistakes in this text.
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
async function proofreadText() {
|
|
60
|
+
try {
|
|
61
|
+
// Submit proofreading job
|
|
62
|
+
const statusUrl = await service.proofread(text);
|
|
63
|
+
console.log('Job submitted. Status URL:', statusUrl);
|
|
64
|
+
|
|
65
|
+
// Fetch results (polls automatically until complete)
|
|
66
|
+
const result = await service.fetchResults(statusUrl);
|
|
67
|
+
const corrections = result.getResultJson();
|
|
68
|
+
|
|
69
|
+
console.log('Original:', text);
|
|
70
|
+
console.log('Corrected:', corrections.corrected_text);
|
|
71
|
+
console.log('Errors found:', corrections.errors.length);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error('Error:', error.message);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
proofreadText();
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## API Documentation
|
|
83
|
+
|
|
84
|
+
### Methods
|
|
85
|
+
|
|
86
|
+
#### `proofread(text: string, language?: string): Promise<string>`
|
|
87
|
+
|
|
88
|
+
Proofreads text and returns corrections for grammar, spelling, and punctuation errors.
|
|
89
|
+
|
|
90
|
+
**Parameters:**
|
|
91
|
+
- `text` (string, required): The text content to proofread
|
|
92
|
+
- `language` (string, optional): The language of the text (default: 'English')
|
|
93
|
+
|
|
94
|
+
**Returns:**
|
|
95
|
+
- Promise<string>: Status URL for polling the job result
|
|
96
|
+
|
|
97
|
+
**Example:**
|
|
98
|
+
```javascript
|
|
99
|
+
const statusUrl = await service.proofread(textWithErrors, 'English');
|
|
100
|
+
const result = await service.fetchResults(statusUrl);
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Response Format
|
|
104
|
+
|
|
105
|
+
The API returns corrected text with detailed error information:
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"corrected_text": "This is a sentence with some errors that need to be fixed. There are several grammatical mistakes in this text.",
|
|
110
|
+
"errors": [
|
|
111
|
+
{
|
|
112
|
+
"error": "sentance",
|
|
113
|
+
"correction": "sentence",
|
|
114
|
+
"type": "spelling",
|
|
115
|
+
"position": 10,
|
|
116
|
+
"explanation": "Incorrect spelling"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"error": "erors",
|
|
120
|
+
"correction": "errors",
|
|
121
|
+
"type": "spelling",
|
|
122
|
+
"position": 30,
|
|
123
|
+
"explanation": "Incorrect spelling"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"error": "Their",
|
|
127
|
+
"correction": "There",
|
|
128
|
+
"type": "grammar",
|
|
129
|
+
"position": 60,
|
|
130
|
+
"explanation": "Wrong usage of 'their' vs 'there'"
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
"error_count": 3
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Examples
|
|
140
|
+
|
|
141
|
+
### Basic Proofreading
|
|
142
|
+
|
|
143
|
+
```javascript
|
|
144
|
+
const { SharpApiProofreadService } = require('@sharpapi/sharpapi-node-proofread');
|
|
145
|
+
|
|
146
|
+
const service = new SharpApiProofreadService(process.env.SHARP_API_KEY);
|
|
147
|
+
|
|
148
|
+
const draft = `
|
|
149
|
+
I has been working on this project for three weeks.
|
|
150
|
+
Its going very good and we should be done soon.
|
|
151
|
+
`;
|
|
152
|
+
|
|
153
|
+
service.proofread(draft)
|
|
154
|
+
.then(statusUrl => service.fetchResults(statusUrl))
|
|
155
|
+
.then(result => {
|
|
156
|
+
const corrections = result.getResultJson();
|
|
157
|
+
console.log('✏️ Corrected text:');
|
|
158
|
+
console.log(corrections.corrected_text);
|
|
159
|
+
console.log(`\n🔍 Found ${corrections.error_count} errors`);
|
|
160
|
+
})
|
|
161
|
+
.catch(error => console.error('Proofreading failed:', error));
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Detailed Error Analysis
|
|
165
|
+
|
|
166
|
+
```javascript
|
|
167
|
+
const service = new SharpApiProofreadService(process.env.SHARP_API_KEY);
|
|
168
|
+
|
|
169
|
+
const document = `
|
|
170
|
+
The company annouced their new product line yesterday.
|
|
171
|
+
We recieved alot of positive feedback from customers.
|
|
172
|
+
`;
|
|
173
|
+
|
|
174
|
+
const statusUrl = await service.proofread(document);
|
|
175
|
+
const result = await service.fetchResults(statusUrl);
|
|
176
|
+
const corrections = result.getResultJson();
|
|
177
|
+
|
|
178
|
+
console.log('Error Report:');
|
|
179
|
+
corrections.errors.forEach((error, index) => {
|
|
180
|
+
console.log(`\n${index + 1}. ${error.type.toUpperCase()}`);
|
|
181
|
+
console.log(` Error: "${error.error}"`);
|
|
182
|
+
console.log(` Correction: "${error.correction}"`);
|
|
183
|
+
console.log(` Explanation: ${error.explanation}`);
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Batch Proofreading
|
|
188
|
+
|
|
189
|
+
```javascript
|
|
190
|
+
const service = new SharpApiProofreadService(process.env.SHARP_API_KEY);
|
|
191
|
+
|
|
192
|
+
const articles = [
|
|
193
|
+
{ title: 'Article 1', content: 'Your text here...' },
|
|
194
|
+
{ title: 'Article 2', content: 'More text...' },
|
|
195
|
+
{ title: 'Article 3', content: 'Even more text...' }
|
|
196
|
+
];
|
|
197
|
+
|
|
198
|
+
const proofreadResults = await Promise.all(
|
|
199
|
+
articles.map(async (article) => {
|
|
200
|
+
const statusUrl = await service.proofread(article.content);
|
|
201
|
+
const result = await service.fetchResults(statusUrl);
|
|
202
|
+
const corrections = result.getResultJson();
|
|
203
|
+
|
|
204
|
+
return {
|
|
205
|
+
title: article.title,
|
|
206
|
+
original: article.content,
|
|
207
|
+
corrected: corrections.corrected_text,
|
|
208
|
+
error_count: corrections.error_count
|
|
209
|
+
};
|
|
210
|
+
})
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
proofreadResults.forEach(result => {
|
|
214
|
+
console.log(`${result.title}: ${result.error_count} errors corrected`);
|
|
215
|
+
});
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Use Cases
|
|
221
|
+
|
|
222
|
+
- **Content Creation**: Ensure error-free blog posts, articles, and marketing copy
|
|
223
|
+
- **Email Communication**: Polish professional emails and messages
|
|
224
|
+
- **Academic Writing**: Improve essays, papers, and research documents
|
|
225
|
+
- **Business Documents**: Perfect reports, proposals, and presentations
|
|
226
|
+
- **Social Media**: Check posts for grammar and spelling before publishing
|
|
227
|
+
- **E-commerce**: Ensure product descriptions are error-free
|
|
228
|
+
- **Customer Support**: Validate support responses for clarity and correctness
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Detection Capabilities
|
|
233
|
+
|
|
234
|
+
The proofreader identifies various types of errors:
|
|
235
|
+
|
|
236
|
+
- **Spelling errors**: Typos, misspelled words
|
|
237
|
+
- **Grammar mistakes**: Subject-verb agreement, tense errors
|
|
238
|
+
- **Punctuation**: Missing or incorrect punctuation marks
|
|
239
|
+
- **Capitalization**: Proper noun capitalization, sentence starts
|
|
240
|
+
- **Word choice**: Commonly confused words (their/there/they're)
|
|
241
|
+
- **Style issues**: Redundancy, wordiness, clarity problems
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## API Endpoint
|
|
246
|
+
|
|
247
|
+
**POST** `/content/proofread`
|
|
248
|
+
|
|
249
|
+
For detailed API specifications, refer to:
|
|
250
|
+
- [Postman Documentation](https://documenter.getpostman.com/view/31106842/2sBXVeGsVc)
|
|
251
|
+
- [Product Page](https://sharpapi.com/en/catalog/ai/content-marketing-automation/proofread-grammar-checker)
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Related Packages
|
|
256
|
+
|
|
257
|
+
- [@sharpapi/sharpapi-node-paraphrase](https://www.npmjs.com/package/@sharpapi/sharpapi-node-paraphrase) - Text paraphrasing
|
|
258
|
+
- [@sharpapi/sharpapi-node-translate](https://www.npmjs.com/package/@sharpapi/sharpapi-node-translate) - Text translation
|
|
259
|
+
- [@sharpapi/sharpapi-node-summarize-text](https://www.npmjs.com/package/@sharpapi/sharpapi-node-summarize-text) - Text summarization
|
|
260
|
+
- [@sharpapi/sharpapi-node-client](https://www.npmjs.com/package/@sharpapi/sharpapi-node-client) - Full SharpAPI SDK
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## License
|
|
265
|
+
|
|
266
|
+
This project is licensed under the MIT License. See the [LICENSE.md](LICENSE.md) file for details.
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Support
|
|
271
|
+
|
|
272
|
+
- **Documentation**: [SharpAPI.com Documentation](https://sharpapi.com/documentation)
|
|
273
|
+
- **Issues**: [GitHub Issues](https://github.com/sharpapi/sharpapi-node-client/issues)
|
|
274
|
+
- **Email**: contact@sharpapi.com
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
**Powered by [SharpAPI](https://sharpapi.com/) - AI-Powered API Workflow Automation**
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sharpapi/sharpapi-node-proofread",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SharpAPI.com Node.js SDK for proofreading text",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "jest"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"sharpapi",
|
|
11
|
+
"ai-powered",
|
|
12
|
+
"ai capabilities",
|
|
13
|
+
"api",
|
|
14
|
+
"ai api",
|
|
15
|
+
"api integration",
|
|
16
|
+
"artificial intelligence",
|
|
17
|
+
"natural language processing",
|
|
18
|
+
"restful api",
|
|
19
|
+
"nodejs",
|
|
20
|
+
"software development",
|
|
21
|
+
"content analysis",
|
|
22
|
+
"proofreading",
|
|
23
|
+
"grammar checking"
|
|
24
|
+
],
|
|
25
|
+
"author": "Dawid Makowski <contact@sharpapi.com>",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@sharpapi/sharpapi-node-core": "file:../sharpapi-node-core"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"jest": "^29.7.0"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/sharpapi/sharpapi-node-proofread.git"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const { SharpApiCoreService, SharpApiJobTypeEnum } = require('@sharpapi/sharpapi-node-core');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Service for proofreading text using SharpAPI.com
|
|
5
|
+
*/
|
|
6
|
+
class SharpApiProofreadService extends SharpApiCoreService {
|
|
7
|
+
/**
|
|
8
|
+
* Proofreads (and checks grammar) of the provided text.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} text
|
|
11
|
+
* @returns {Promise<string>} - The status URL.
|
|
12
|
+
*/
|
|
13
|
+
async proofread(text) {
|
|
14
|
+
const data = { content: text };
|
|
15
|
+
const response = await this.makeRequest('POST', SharpApiJobTypeEnum.CONTENT_PROOFREAD.url, data);
|
|
16
|
+
return this.parseStatusUrl(response);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = { SharpApiProofreadService };
|