humanizedtext 0.1.0 → 0.1.1
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 +236 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,36 +1,259 @@
|
|
|
1
1
|
# humanizedtext (npm)
|
|
2
2
|
|
|
3
|
-
Official JavaScript SDK for HumanizedText API.
|
|
3
|
+
Official JavaScript SDK for the HumanizedText API.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This SDK wraps the authenticated SDK endpoints exposed by HumanizedText and provides:
|
|
6
|
+
|
|
7
|
+
- API key authentication via `X-API-Key`
|
|
8
|
+
- Request timeout handling
|
|
9
|
+
- Typed runtime errors (`HumanizedTextAPIError`)
|
|
10
|
+
- Clean methods for humanize, grammar fix, rewrite, and SEO blog writing
|
|
11
|
+
|
|
12
|
+
## Contents
|
|
13
|
+
|
|
14
|
+
1. Requirements
|
|
15
|
+
2. Installation
|
|
16
|
+
3. Authentication
|
|
17
|
+
4. Client Configuration
|
|
18
|
+
5. API Methods
|
|
19
|
+
6. Response Examples
|
|
20
|
+
7. Error Handling
|
|
21
|
+
8. Edge Cases and Limits
|
|
22
|
+
9. Production Recommendations
|
|
23
|
+
|
|
24
|
+
## Requirements
|
|
25
|
+
|
|
26
|
+
- Node.js `>=18`
|
|
27
|
+
- A valid HumanizedText API key
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
6
30
|
|
|
7
31
|
```bash
|
|
8
32
|
npm install humanizedtext
|
|
9
33
|
```
|
|
10
34
|
|
|
11
|
-
##
|
|
35
|
+
## Authentication
|
|
36
|
+
|
|
37
|
+
The SDK sends your key in the `X-API-Key` header.
|
|
38
|
+
|
|
39
|
+
Generate/manage your key from your HumanizedText dashboard, then initialize the client with it.
|
|
12
40
|
|
|
13
41
|
```js
|
|
14
42
|
const { HumanizedTextClient } = require("humanizedtext");
|
|
15
43
|
|
|
44
|
+
const client = new HumanizedTextClient({
|
|
45
|
+
apiKey: process.env.HUMANIZEDTEXT_API_KEY,
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Client Configuration
|
|
50
|
+
|
|
51
|
+
```js
|
|
16
52
|
const client = new HumanizedTextClient({
|
|
17
53
|
apiKey: "YOUR_API_KEY",
|
|
18
54
|
baseUrl: "https://api.humanizedtext.pro/api/v1",
|
|
55
|
+
timeout: 60000,
|
|
19
56
|
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
| Option | Type | Required | Default | Description |
|
|
60
|
+
|---|---|---|---|---|
|
|
61
|
+
| `apiKey` | `string` | Yes | - | HumanizedText API key |
|
|
62
|
+
| `baseUrl` | `string` | No | `https://api.humanizedtext.pro/api/v1` | API base URL |
|
|
63
|
+
| `timeout` | `number` | No | `60000` | Request timeout in milliseconds |
|
|
20
64
|
|
|
21
|
-
|
|
22
|
-
|
|
65
|
+
## API Methods
|
|
66
|
+
|
|
67
|
+
### 1) `humanize(params)`
|
|
68
|
+
|
|
69
|
+
Humanizes input text with optional tone, keyword insertion, and ultra mode.
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
const res = await client.humanize({
|
|
73
|
+
text: "Your AI-like text here",
|
|
23
74
|
tone: "professional",
|
|
24
|
-
ultraHumanize:
|
|
25
|
-
keywords: ["
|
|
75
|
+
ultraHumanize: false,
|
|
76
|
+
keywords: ["SaaS", "conversion"],
|
|
26
77
|
});
|
|
78
|
+
```
|
|
27
79
|
|
|
28
|
-
|
|
80
|
+
| Param | Type | Required | Default | Notes |
|
|
81
|
+
|---|---|---|---|---|
|
|
82
|
+
| `text` | `string` | Yes | - | Must be `1..6000` characters |
|
|
83
|
+
| `tone` | `string \| null` | No | `null` | Example: `professional`, `casual`, `friendly`, `default` |
|
|
84
|
+
| `ultraHumanize` | `boolean` | No | `false` | Uses ultra quota per request when `true` |
|
|
85
|
+
| `keywords` | `string[] \| null` | No | `null` | Plan-limited count per request |
|
|
86
|
+
|
|
87
|
+
### 2) `grammarFixer(params)`
|
|
88
|
+
|
|
89
|
+
Fixes grammar while preserving meaning.
|
|
90
|
+
|
|
91
|
+
```js
|
|
92
|
+
const res = await client.grammarFixer({ text: "this are a sentence." });
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
| Param | Type | Required | Notes |
|
|
96
|
+
|---|---|---|---|
|
|
97
|
+
| `text` | `string` | Yes | Must be `1..6000` characters |
|
|
98
|
+
|
|
99
|
+
### 3) `contentRewriter(params)`
|
|
100
|
+
|
|
101
|
+
Rewrites content to improve readability/originality.
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
const res = await client.contentRewriter({
|
|
105
|
+
text: "Original paragraph to rewrite",
|
|
106
|
+
});
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
| Param | Type | Required | Notes |
|
|
110
|
+
|---|---|---|---|
|
|
111
|
+
| `text` | `string` | Yes | Must be `1..6000` characters |
|
|
112
|
+
|
|
113
|
+
### 4) `seoBlogWriter(params)`
|
|
114
|
+
|
|
115
|
+
Generates SEO-focused blog content from a topic.
|
|
116
|
+
|
|
117
|
+
```js
|
|
118
|
+
const res = await client.seoBlogWriter({ topic: "Best CRM tools for startups" });
|
|
29
119
|
```
|
|
30
120
|
|
|
31
|
-
|
|
121
|
+
| Param | Type | Required | Notes |
|
|
122
|
+
|---|---|---|---|
|
|
123
|
+
| `topic` | `string` | Yes | Must be `1..500` characters |
|
|
124
|
+
|
|
125
|
+
## Response Examples
|
|
126
|
+
|
|
127
|
+
Actual responses are JSON objects. Common shapes:
|
|
128
|
+
|
|
129
|
+
### Humanize response
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"original_text": "Your original text",
|
|
134
|
+
"humanized_text": "Humanized output text",
|
|
135
|
+
"tone_applied": "professional",
|
|
136
|
+
"ultra_humanize_used": false,
|
|
137
|
+
"keywords_used": ["SaaS", "conversion"],
|
|
138
|
+
"created_at": "2026-04-12T15:20:11.891000+00:00"
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Grammar fixer response
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"original_text": "this are a sentence.",
|
|
147
|
+
"corrected_text": "This is a sentence.",
|
|
148
|
+
"created_at": "2026-04-12T15:21:17.003000+00:00"
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Content rewriter response
|
|
153
|
+
|
|
154
|
+
```json
|
|
155
|
+
{
|
|
156
|
+
"original_text": "Old copy here",
|
|
157
|
+
"rewritten_text": "Rewritten copy here",
|
|
158
|
+
"created_at": "2026-04-12T15:22:40.221000+00:00"
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### SEO blog writer response
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
{
|
|
166
|
+
"topic": "Best CRM tools for startups",
|
|
167
|
+
"blog_content": "# Best CRM tools for startups\n...",
|
|
168
|
+
"created_at": "2026-04-12T15:23:35.552000+00:00"
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Error Handling
|
|
173
|
+
|
|
174
|
+
The SDK throws `HumanizedTextAPIError` for HTTP failures.
|
|
175
|
+
|
|
176
|
+
```js
|
|
177
|
+
const { HumanizedTextClient, HumanizedTextAPIError } = require("humanizedtext");
|
|
178
|
+
|
|
179
|
+
try {
|
|
180
|
+
await client.humanize({ text: "" });
|
|
181
|
+
} catch (err) {
|
|
182
|
+
if (err instanceof HumanizedTextAPIError) {
|
|
183
|
+
console.error("status:", err.statusCode);
|
|
184
|
+
console.error("payload:", err.payload);
|
|
185
|
+
} else {
|
|
186
|
+
console.error("unexpected:", err);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
`HumanizedTextAPIError` fields:
|
|
192
|
+
|
|
193
|
+
| Field | Type | Description |
|
|
194
|
+
|---|---|---|
|
|
195
|
+
| `message` | `string` | Error detail string |
|
|
196
|
+
| `statusCode` | `number \| undefined` | HTTP status code |
|
|
197
|
+
| `payload` | `unknown` | Raw parsed API payload |
|
|
198
|
+
|
|
199
|
+
## Edge Cases and Limits
|
|
200
|
+
|
|
201
|
+
### Text length
|
|
202
|
+
|
|
203
|
+
- `text` must be `1..6000` chars for humanize/grammar/rewrite.
|
|
204
|
+
- `topic` must be `1..500` chars for SEO blog writer.
|
|
205
|
+
|
|
206
|
+
Typical failure: `400 Bad Request`.
|
|
207
|
+
|
|
208
|
+
### Invalid API key
|
|
209
|
+
|
|
210
|
+
Typical failure: `401 Unauthorized`.
|
|
211
|
+
|
|
212
|
+
### Plan character quota exceeded
|
|
213
|
+
|
|
214
|
+
Typical failure: `402 Payment Required`.
|
|
215
|
+
`detail` may be an object like:
|
|
216
|
+
|
|
217
|
+
```json
|
|
218
|
+
{
|
|
219
|
+
"message": "SDK character limit exceeded for current period",
|
|
220
|
+
"plan": "free",
|
|
221
|
+
"characters_needed": 1200,
|
|
222
|
+
"remaining_characters": 0,
|
|
223
|
+
"period_resets_at": "2026-04-30T00:00:00+00:00"
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Ultra mode quota exceeded
|
|
228
|
+
|
|
229
|
+
Typical failure: `429 Too Many Requests` with remaining ultra count.
|
|
230
|
+
|
|
231
|
+
### Keywords per request limit exceeded
|
|
232
|
+
|
|
233
|
+
Typical failure: `400 Bad Request`.
|
|
234
|
+
`detail` may include:
|
|
235
|
+
|
|
236
|
+
```json
|
|
237
|
+
{
|
|
238
|
+
"message": "Keyword limit exceeded",
|
|
239
|
+
"max_keywords_allowed": 1,
|
|
240
|
+
"keywords_provided": 3,
|
|
241
|
+
"upgrade_required": true
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Timeout and network failures
|
|
246
|
+
|
|
247
|
+
- The SDK aborts after `timeout` milliseconds.
|
|
248
|
+
- Network failures are thrown as native runtime errors.
|
|
249
|
+
|
|
250
|
+
## Production Recommendations
|
|
251
|
+
|
|
252
|
+
- Store API keys in environment variables, never hardcode them.
|
|
253
|
+
- Implement retry with exponential backoff for transient 5xx or network errors.
|
|
254
|
+
- Log `statusCode` and `payload` from `HumanizedTextAPIError` for observability.
|
|
255
|
+
- Validate and trim user input before sending to avoid avoidable 400s.
|
|
256
|
+
|
|
257
|
+
## License
|
|
32
258
|
|
|
33
|
-
|
|
34
|
-
- `grammarFixer({ text })`
|
|
35
|
-
- `contentRewriter({ text })`
|
|
36
|
-
- `seoBlogWriter({ topic })`
|
|
259
|
+
MIT
|