humanizedtext 0.1.0 → 0.1.2

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.
Files changed (2) hide show
  1. package/README.md +238 -13
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,36 +1,261 @@
1
1
  # humanizedtext (npm)
2
2
 
3
- Official JavaScript SDK for HumanizedText API.
3
+ Official JavaScript SDK for the HumanizedText API.
4
4
 
5
- ## Install
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
- ## Quick Start
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
- const result = await client.humanize({
22
- text: "This is a sample text.",
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: true,
25
- keywords: ["SEO", "AI writing"],
75
+ ultraHumanize: false,
76
+ keywords: ["SaaS", "conversion"],
26
77
  });
78
+ ```
79
+
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({
119
+ topic: "Best CRM tools for startups",
120
+ });
121
+ ```
27
122
 
28
- console.log(result);
123
+ | Param | Type | Required | Notes |
124
+ | ------- | -------- | -------- | --------------------------- |
125
+ | `topic` | `string` | Yes | Must be `1..500` characters |
126
+
127
+ ## Response Examples
128
+
129
+ Actual responses are JSON objects. Common shapes:
130
+
131
+ ### Humanize response
132
+
133
+ ```json
134
+ {
135
+ "original_text": "Your original text",
136
+ "humanized_text": "Humanized output text",
137
+ "tone_applied": "professional",
138
+ "ultra_humanize_used": false,
139
+ "keywords_used": ["SaaS", "conversion"],
140
+ "created_at": "2026-04-12T15:20:11.891000+00:00"
141
+ }
29
142
  ```
30
143
 
31
- ## Methods
144
+ ### Grammar fixer response
145
+
146
+ ```json
147
+ {
148
+ "original_text": "this are a sentence.",
149
+ "corrected_text": "This is a sentence.",
150
+ "created_at": "2026-04-12T15:21:17.003000+00:00"
151
+ }
152
+ ```
153
+
154
+ ### Content rewriter response
155
+
156
+ ```json
157
+ {
158
+ "original_text": "Old copy here",
159
+ "rewritten_text": "Rewritten copy here",
160
+ "created_at": "2026-04-12T15:22:40.221000+00:00"
161
+ }
162
+ ```
163
+
164
+ ### SEO blog writer response
165
+
166
+ ```json
167
+ {
168
+ "topic": "Best CRM tools for startups",
169
+ "blog_content": "# Best CRM tools for startups\n...",
170
+ "created_at": "2026-04-12T15:23:35.552000+00:00"
171
+ }
172
+ ```
173
+
174
+ ## Error Handling
175
+
176
+ The SDK throws `HumanizedTextAPIError` for HTTP failures.
177
+
178
+ ```js
179
+ const { HumanizedTextClient, HumanizedTextAPIError } = require("humanizedtext");
180
+
181
+ try {
182
+ await client.humanize({ text: "" });
183
+ } catch (err) {
184
+ if (err instanceof HumanizedTextAPIError) {
185
+ console.error("status:", err.statusCode);
186
+ console.error("payload:", err.payload);
187
+ } else {
188
+ console.error("unexpected:", err);
189
+ }
190
+ }
191
+ ```
192
+
193
+ `HumanizedTextAPIError` fields:
194
+
195
+ | Field | Type | Description |
196
+ | ------------ | --------------------- | ---------------------- |
197
+ | `message` | `string` | Error detail string |
198
+ | `statusCode` | `number \| undefined` | HTTP status code |
199
+ | `payload` | `unknown` | Raw parsed API payload |
200
+
201
+ ## Edge Cases and Limits
202
+
203
+ ### Text length
204
+
205
+ - `text` must be `1..6000` chars for humanize/grammar/rewrite.
206
+ - `topic` must be `1..500` chars for SEO blog writer.
207
+
208
+ Typical failure: `400 Bad Request`.
209
+
210
+ ### Invalid API key
211
+
212
+ Typical failure: `401 Unauthorized`.
213
+
214
+ ### Plan character quota exceeded
215
+
216
+ Typical failure: `402 Payment Required`.
217
+ `detail` may be an object like:
218
+
219
+ ```json
220
+ {
221
+ "message": "SDK character limit exceeded for current period",
222
+ "plan": "free",
223
+ "characters_needed": 1200,
224
+ "remaining_characters": 0,
225
+ "period_resets_at": "2026-04-30T00:00:00+00:00"
226
+ }
227
+ ```
228
+
229
+ ### Ultra mode quota exceeded
230
+
231
+ Typical failure: `429 Too Many Requests` with remaining ultra count.
232
+
233
+ ### Keywords per request limit exceeded
234
+
235
+ Typical failure: `400 Bad Request`.
236
+ `detail` may include:
237
+
238
+ ```json
239
+ {
240
+ "message": "Keyword limit exceeded",
241
+ "max_keywords_allowed": 1,
242
+ "keywords_provided": 3,
243
+ "upgrade_required": true
244
+ }
245
+ ```
246
+
247
+ ### Timeout and network failures
248
+
249
+ - The SDK aborts after `timeout` milliseconds.
250
+ - Network failures are thrown as native runtime errors.
251
+
252
+ ## Production Recommendations
253
+
254
+ - Store API keys in environment variables, never hardcode them.
255
+ - Implement retry with exponential backoff for transient 5xx or network errors.
256
+ - Log `statusCode` and `payload` from `HumanizedTextAPIError` for observability.
257
+ - Validate and trim user input before sending to avoid avoidable 400s.
258
+
259
+ ## License
32
260
 
33
- - `humanize({ text, tone, ultraHumanize, keywords })`
34
- - `grammarFixer({ text })`
35
- - `contentRewriter({ text })`
36
- - `seoBlogWriter({ topic })`
261
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "humanizedtext",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Official JavaScript SDK for HumanizedText API",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",