@sharpapi/sharpapi-node-generate-keywords 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 ADDED
@@ -0,0 +1,277 @@
1
+ ![SharpAPI GitHub cover](https://sharpapi.com/sharpapi-github-php-bg.jpg "SharpAPI Node.js Client")
2
+
3
+ # Keywords & Tags Generator API for Node.js
4
+
5
+ ## 🏷️ Extract keywords and generate tags from text — powered by SharpAPI AI.
6
+
7
+ [![npm version](https://img.shields.io/npm/v/@sharpapi/sharpapi-node-generate-keywords.svg)](https://www.npmjs.com/package/@sharpapi/sharpapi-node-generate-keywords)
8
+ [![License](https://img.shields.io/npm/l/@sharpapi/sharpapi-node-generate-keywords.svg)](https://github.com/sharpapi/sharpapi-node-client/blob/master/LICENSE.md)
9
+
10
+ **SharpAPI Keywords & Tags Generator** uses advanced AI to extract relevant keywords and generate tags from text content. Perfect for SEO, content categorization, and metadata generation.
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-generate-keywords
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 { SharpApiGenerateKeywordsService } = require('@sharpapi/sharpapi-node-generate-keywords');
50
+
51
+ const apiKey = process.env.SHARP_API_KEY; // Store your API key in environment variables
52
+ const service = new SharpApiGenerateKeywordsService(apiKey);
53
+
54
+ const text = `
55
+ Cloud computing has revolutionized how businesses operate by providing on-demand access
56
+ to computing resources. Companies can now scale their infrastructure automatically based
57
+ on demand, reducing costs and improving efficiency.
58
+ `;
59
+
60
+ async function generateKeywords() {
61
+ try {
62
+ // Submit keyword generation job
63
+ const statusUrl = await service.generateKeywords(text);
64
+ console.log('Job submitted. Status URL:', statusUrl);
65
+
66
+ // Fetch results (polls automatically until complete)
67
+ const result = await service.fetchResults(statusUrl);
68
+ const keywords = result.getResultJson();
69
+
70
+ console.log('Generated keywords:', keywords);
71
+ } catch (error) {
72
+ console.error('Error:', error.message);
73
+ }
74
+ }
75
+
76
+ generateKeywords();
77
+ ```
78
+
79
+ ---
80
+
81
+ ## API Documentation
82
+
83
+ ### Methods
84
+
85
+ #### `generateKeywords(text: string, maxKeywords?: number, language?: string): Promise<string>`
86
+
87
+ Extracts keywords and generates tags from the provided text.
88
+
89
+ **Parameters:**
90
+ - `text` (string, required): The text content to analyze
91
+ - `maxKeywords` (number, optional): Maximum number of keywords to return (default: 10)
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.generateKeywords(articleText, 15, 'English');
100
+ const result = await service.fetchResults(statusUrl);
101
+ ```
102
+
103
+ ### Response Format
104
+
105
+ The API returns extracted keywords with relevance scores:
106
+
107
+ ```json
108
+ {
109
+ "keywords": [
110
+ {
111
+ "keyword": "cloud computing",
112
+ "relevance": 0.95,
113
+ "occurrences": 3
114
+ },
115
+ {
116
+ "keyword": "on-demand access",
117
+ "relevance": 0.88,
118
+ "occurrences": 2
119
+ },
120
+ {
121
+ "keyword": "computing resources",
122
+ "relevance": 0.82,
123
+ "occurrences": 2
124
+ }
125
+ ],
126
+ "tags": [
127
+ "cloud-computing",
128
+ "infrastructure",
129
+ "scalability",
130
+ "business-technology"
131
+ ]
132
+ }
133
+ ```
134
+
135
+ ---
136
+
137
+ ## Examples
138
+
139
+ ### Basic Keyword Extraction
140
+
141
+ ```javascript
142
+ const { SharpApiGenerateKeywordsService } = require('@sharpapi/sharpapi-node-generate-keywords');
143
+
144
+ const service = new SharpApiGenerateKeywordsService(process.env.SHARP_API_KEY);
145
+
146
+ const blogPost = `
147
+ Artificial intelligence is transforming healthcare through predictive analytics,
148
+ personalized treatment plans, and automated diagnostics. Machine learning algorithms
149
+ can now detect diseases earlier than traditional methods.
150
+ `;
151
+
152
+ service.generateKeywords(blogPost, 8)
153
+ .then(statusUrl => service.fetchResults(statusUrl))
154
+ .then(result => {
155
+ const data = result.getResultJson();
156
+ console.log('🔑 Top Keywords:');
157
+ data.keywords.forEach((kw, index) => {
158
+ console.log(`${index + 1}. ${kw.keyword} (relevance: ${kw.relevance})`);
159
+ });
160
+ console.log('\n🏷️ Suggested Tags:', data.tags.join(', '));
161
+ })
162
+ .catch(error => console.error('Generation failed:', error));
163
+ ```
164
+
165
+ ### SEO Keyword Analysis
166
+
167
+ ```javascript
168
+ const service = new SharpApiGenerateKeywordsService(process.env.SHARP_API_KEY);
169
+
170
+ const productDescription = `
171
+ Professional noise-canceling wireless headphones with 40-hour battery life.
172
+ Features advanced Bluetooth 5.0 technology, premium sound quality, and
173
+ comfortable over-ear design. Perfect for travel, work, and entertainment.
174
+ `;
175
+
176
+ const statusUrl = await service.generateKeywords(productDescription, 12);
177
+ const result = await service.fetchResults(statusUrl);
178
+ const keywordData = result.getResultJson();
179
+
180
+ // Filter high-relevance keywords for SEO
181
+ const seoKeywords = keywordData.keywords
182
+ .filter(kw => kw.relevance >= 0.8)
183
+ .map(kw => kw.keyword);
184
+
185
+ console.log('High-value SEO keywords:', seoKeywords);
186
+ ```
187
+
188
+ ### Content Categorization
189
+
190
+ ```javascript
191
+ const service = new SharpApiGenerateKeywordsService(process.env.SHARP_API_KEY);
192
+
193
+ const articles = [
194
+ { id: 1, content: 'Article about web development...' },
195
+ { id: 2, content: 'Article about digital marketing...' },
196
+ { id: 3, content: 'Article about machine learning...' }
197
+ ];
198
+
199
+ const categorized = await Promise.all(
200
+ articles.map(async (article) => {
201
+ const statusUrl = await service.generateKeywords(article.content, 5);
202
+ const result = await service.fetchResults(statusUrl);
203
+ const data = result.getResultJson();
204
+
205
+ return {
206
+ id: article.id,
207
+ category: data.tags[0], // Primary category
208
+ keywords: data.keywords.slice(0, 3).map(kw => kw.keyword),
209
+ tags: data.tags
210
+ };
211
+ })
212
+ );
213
+
214
+ console.log('Categorized content:', categorized);
215
+ ```
216
+
217
+ ---
218
+
219
+ ## Use Cases
220
+
221
+ - **SEO Optimization**: Generate keywords for meta tags and content optimization
222
+ - **Content Categorization**: Auto-tag articles, products, and documents
223
+ - **Search Enhancement**: Improve search functionality with extracted keywords
224
+ - **Metadata Generation**: Automatically create metadata for CMS systems
225
+ - **Topic Modeling**: Identify main topics and themes in text
226
+ - **Content Discovery**: Enable better content recommendations
227
+ - **Analytics**: Track keyword trends and content themes
228
+
229
+ ---
230
+
231
+ ## Keyword Types
232
+
233
+ The generator identifies various keyword types:
234
+
235
+ - **Single Keywords**: Individual important terms
236
+ - **Key Phrases**: Multi-word expressions (2-4 words)
237
+ - **Named Entities**: People, places, organizations
238
+ - **Technical Terms**: Industry-specific terminology
239
+ - **Action Words**: Verbs and action-oriented phrases
240
+ - **Topic Tags**: High-level categorical tags
241
+
242
+ ---
243
+
244
+ ## API Endpoint
245
+
246
+ **POST** `/content/keywords`
247
+
248
+ For detailed API specifications, refer to:
249
+ - [Postman Documentation](https://documenter.getpostman.com/view/31106842/2sBXVeGsVX)
250
+ - [Product Page](https://sharpapi.com/en/catalog/ai/content-marketing-automation/keywords-tags-generator)
251
+
252
+ ---
253
+
254
+ ## Related Packages
255
+
256
+ - [@sharpapi/sharpapi-node-summarize-text](https://www.npmjs.com/package/@sharpapi/sharpapi-node-summarize-text) - Text summarization
257
+ - [@sharpapi/sharpapi-node-seo-tags](https://www.npmjs.com/package/@sharpapi/sharpapi-node-seo-tags) - SEO tags generation
258
+ - [@sharpapi/sharpapi-node-product-categories](https://www.npmjs.com/package/@sharpapi/sharpapi-node-product-categories) - Product categorization
259
+ - [@sharpapi/sharpapi-node-client](https://www.npmjs.com/package/@sharpapi/sharpapi-node-client) - Full SharpAPI SDK
260
+
261
+ ---
262
+
263
+ ## License
264
+
265
+ This project is licensed under the MIT License. See the [LICENSE.md](LICENSE.md) file for details.
266
+
267
+ ---
268
+
269
+ ## Support
270
+
271
+ - **Documentation**: [SharpAPI.com Documentation](https://sharpapi.com/documentation)
272
+ - **Issues**: [GitHub Issues](https://github.com/sharpapi/sharpapi-node-client/issues)
273
+ - **Email**: contact@sharpapi.com
274
+
275
+ ---
276
+
277
+ **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-generate-keywords",
3
+ "version": "1.0.0",
4
+ "description": "SharpAPI.com Node.js SDK for generating keywords from 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
+ "keyword generation",
23
+ "text processing"
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-generate-keywords.git"
39
+ }
40
+ }
@@ -0,0 +1,29 @@
1
+ const { SharpApiCoreService, SharpApiJobTypeEnum } = require('@sharpapi/sharpapi-node-core');
2
+
3
+ /**
4
+ * Service for generating keywords from text using SharpAPI.com
5
+ */
6
+ class SharpApiGenerateKeywordsService extends SharpApiCoreService {
7
+ /**
8
+ * Generates a list of unique keywords/tags based on the provided content.
9
+ *
10
+ * @param {string} text
11
+ * @param {string|null} language
12
+ * @param {number|null} maxQuantity
13
+ * @param {string|null} voiceTone
14
+ * @param {string|null} context
15
+ * @returns {Promise<string>} - The status URL.
16
+ */
17
+ async generateKeywords(text, language = null, maxQuantity = null, voiceTone = null, context = null) {
18
+ const data = { content: text };
19
+ if (language) data.language = language;
20
+ if (maxQuantity) data.max_quantity = maxQuantity;
21
+ if (voiceTone) data.voice_tone = voiceTone;
22
+ if (context) data.context = context;
23
+
24
+ const response = await this.makeRequest('POST', SharpApiJobTypeEnum.CONTENT_KEYWORDS.url, data);
25
+ return this.parseStatusUrl(response);
26
+ }
27
+ }
28
+
29
+ module.exports = { SharpApiGenerateKeywordsService };
package/src/index.js ADDED
@@ -0,0 +1,6 @@
1
+ // sharpapi-node-generate-keywords/src/index.js
2
+ const { SharpApiGenerateKeywordsService } = require('./SharpApiGenerateKeywordsService');
3
+
4
+ module.exports = {
5
+ SharpApiGenerateKeywordsService,
6
+ };