@sharpapi/sharpapi-node-tours-activities-categories 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 +386 -0
- package/package.json +42 -0
- package/src/SharpApiToursActivitiesCategoriesService.js +36 -0
- package/src/index.js +6 -0
package/README.md
ADDED
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
# Tours & Activities Categorization API for Node.js
|
|
4
|
+
|
|
5
|
+
## 🎠Automatically categorize tours and activities with AI — powered by SharpAPI.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@sharpapi/sharpapi-node-tours-activities-categories)
|
|
8
|
+
[](https://github.com/sharpapi/sharpapi-node-client/blob/master/LICENSE.md)
|
|
9
|
+
|
|
10
|
+
**SharpAPI Tours & Activities Categorization** uses AI to automatically categorize tours, excursions, activities, and experiences based on their descriptions. Perfect for travel platforms, tour operators, and activity booking systems.
|
|
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. [Response Format](#response-format)
|
|
21
|
+
6. [Examples](#examples)
|
|
22
|
+
7. [License](#license)
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Requirements
|
|
27
|
+
|
|
28
|
+
- Node.js >= 16.x
|
|
29
|
+
- npm or yarn
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
### Step 1. Install the package via npm:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install @sharpapi/sharpapi-node-tours-activities-categories
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Step 2. Get your API key
|
|
42
|
+
|
|
43
|
+
Visit [SharpAPI.com](https://sharpapi.com/) to get your API key.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
const { SharpApiToursActivitiesCategoriesService } = require('@sharpapi/sharpapi-node-tours-activities-categories');
|
|
51
|
+
|
|
52
|
+
const apiKey = process.env.SHARP_API_KEY;
|
|
53
|
+
const service = new SharpApiToursActivitiesCategoriesService(apiKey);
|
|
54
|
+
|
|
55
|
+
const activityDescription = `
|
|
56
|
+
Full-day wine tasting tour through Napa Valley. Visit 4 premium wineries,
|
|
57
|
+
enjoy gourmet lunch, and learn about wine-making process from expert sommeliers.
|
|
58
|
+
Small group experience with hotel pickup included.
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
async function categorizeActivity() {
|
|
62
|
+
try {
|
|
63
|
+
const statusUrl = await service.categorizeProduct(activityDescription);
|
|
64
|
+
console.log('Job submitted. Status URL:', statusUrl);
|
|
65
|
+
|
|
66
|
+
const result = await service.fetchResults(statusUrl);
|
|
67
|
+
console.log('Categories:', result.getResultJson());
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error('Error:', error.message);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
categorizeActivity();
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## API Documentation
|
|
79
|
+
|
|
80
|
+
### Methods
|
|
81
|
+
|
|
82
|
+
#### `categorizeProduct(activityDescription: string, maxCategories?: number): Promise<string>`
|
|
83
|
+
|
|
84
|
+
Categorizes a tour or activity based on its description.
|
|
85
|
+
|
|
86
|
+
**Parameters:**
|
|
87
|
+
- `activityDescription` (string, required): The tour/activity description to categorize
|
|
88
|
+
- `maxCategories` (number, optional): Maximum number of categories to return (default: 5)
|
|
89
|
+
|
|
90
|
+
**Returns:**
|
|
91
|
+
- Promise<string>: Status URL for polling the job result
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Response Format
|
|
96
|
+
|
|
97
|
+
The API returns categories with relevance scores (weight: 0-10):
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"categories": [
|
|
102
|
+
{
|
|
103
|
+
"name": "Food & Wine Tours",
|
|
104
|
+
"weight": 10,
|
|
105
|
+
"subcategories": ["Wine Tasting", "Culinary Experience", "Gourmet Tours"]
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"name": "Cultural Tours",
|
|
109
|
+
"weight": 8,
|
|
110
|
+
"subcategories": ["Educational", "Small Group"]
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"name": "Day Tours",
|
|
114
|
+
"weight": 9,
|
|
115
|
+
"subcategories": ["Full-Day Experience", "Guided Tour"]
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Weight Scale:**
|
|
122
|
+
- `10`: Perfect match
|
|
123
|
+
- `8-9`: Highly relevant
|
|
124
|
+
- `6-7`: Moderately relevant
|
|
125
|
+
- `4-5`: Somewhat relevant
|
|
126
|
+
- `1-3`: Slightly relevant
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Examples
|
|
131
|
+
|
|
132
|
+
### Basic Activity Categorization
|
|
133
|
+
|
|
134
|
+
```javascript
|
|
135
|
+
const { SharpApiToursActivitiesCategoriesService } = require('@sharpapi/sharpapi-node-tours-activities-categories');
|
|
136
|
+
|
|
137
|
+
const service = new SharpApiToursActivitiesCategoriesService(process.env.SHARP_API_KEY);
|
|
138
|
+
|
|
139
|
+
const activity = 'Guided snorkeling adventure with sea turtles. Equipment and lunch included.';
|
|
140
|
+
|
|
141
|
+
service.categorizeProduct(activity)
|
|
142
|
+
.then(statusUrl => service.fetchResults(statusUrl))
|
|
143
|
+
.then(result => {
|
|
144
|
+
const categories = result.getResultJson();
|
|
145
|
+
console.log('🎯 Activity Categories:');
|
|
146
|
+
categories.forEach((cat, index) => {
|
|
147
|
+
console.log(`${index + 1}. ${cat.name} (relevance: ${cat.weight}/10)`);
|
|
148
|
+
if (cat.subcategories) {
|
|
149
|
+
console.log(` Types: ${cat.subcategories.join(', ')}`);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
})
|
|
153
|
+
.catch(error => console.error('Categorization failed:', error));
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Batch Tour Categorization
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
const service = new SharpApiToursActivitiesCategoriesService(process.env.SHARP_API_KEY);
|
|
160
|
+
|
|
161
|
+
const tours = [
|
|
162
|
+
'City walking tour of historical landmarks with professional guide',
|
|
163
|
+
'Sunset sailing cruise with champagne and appetizers',
|
|
164
|
+
'Mountain hiking adventure with experienced trail guide',
|
|
165
|
+
'Cooking class: Learn to make authentic Italian pasta'
|
|
166
|
+
];
|
|
167
|
+
|
|
168
|
+
async function categorizeAllTours(tours) {
|
|
169
|
+
const categorized = await Promise.all(
|
|
170
|
+
tours.map(async (tour) => {
|
|
171
|
+
const statusUrl = await service.categorizeProduct(tour, 3);
|
|
172
|
+
const result = await service.fetchResults(statusUrl);
|
|
173
|
+
const categories = result.getResultJson();
|
|
174
|
+
|
|
175
|
+
return {
|
|
176
|
+
tour,
|
|
177
|
+
primary: categories[0]?.name,
|
|
178
|
+
categories: categories.map(c => c.name),
|
|
179
|
+
tags: categories.flatMap(c => c.subcategories || [])
|
|
180
|
+
};
|
|
181
|
+
})
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
return categorized;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const results = await categorizeAllTours(tours);
|
|
188
|
+
results.forEach(r => {
|
|
189
|
+
console.log(`\n${r.tour}`);
|
|
190
|
+
console.log(`Primary: ${r.primary}`);
|
|
191
|
+
console.log(`Tags: ${r.tags.join(', ')}`);
|
|
192
|
+
});
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Booking Platform Integration
|
|
196
|
+
|
|
197
|
+
```javascript
|
|
198
|
+
const service = new SharpApiToursActivitiesCategoriesService(process.env.SHARP_API_KEY);
|
|
199
|
+
|
|
200
|
+
async function enrichActivityListing(activity) {
|
|
201
|
+
const fullDescription = `
|
|
202
|
+
${activity.title}
|
|
203
|
+
${activity.description}
|
|
204
|
+
Duration: ${activity.duration}
|
|
205
|
+
Included: ${activity.included.join(', ')}
|
|
206
|
+
`;
|
|
207
|
+
|
|
208
|
+
const statusUrl = await service.categorizeProduct(fullDescription);
|
|
209
|
+
const result = await service.fetchResults(statusUrl);
|
|
210
|
+
const categories = result.getResultJson();
|
|
211
|
+
|
|
212
|
+
// Extract primary categories
|
|
213
|
+
const primaryCategories = categories
|
|
214
|
+
.filter(cat => cat.weight >= 7)
|
|
215
|
+
.map(cat => cat.name);
|
|
216
|
+
|
|
217
|
+
// Build search tags
|
|
218
|
+
const searchTags = [
|
|
219
|
+
...primaryCategories,
|
|
220
|
+
...categories.flatMap(c => c.subcategories || [])
|
|
221
|
+
].filter((tag, index, self) => self.indexOf(tag) === index);
|
|
222
|
+
|
|
223
|
+
return {
|
|
224
|
+
...activity,
|
|
225
|
+
categories: primaryCategories,
|
|
226
|
+
tags: searchTags,
|
|
227
|
+
searchable: searchTags.join(' ').toLowerCase(),
|
|
228
|
+
featured_badge: categories[0]?.weight === 10 ? categories[0].name : null
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const activity = {
|
|
233
|
+
id: 'ACT-789',
|
|
234
|
+
title: 'Zip Line Canopy Tour',
|
|
235
|
+
description: 'Thrilling adventure through rainforest canopy',
|
|
236
|
+
duration: '3 hours',
|
|
237
|
+
included: ['Safety equipment', 'Guide', 'Photos']
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
const enriched = await enrichActivityListing(activity);
|
|
241
|
+
console.log('Enriched activity:', enriched);
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Smart Activity Recommendations
|
|
245
|
+
|
|
246
|
+
```javascript
|
|
247
|
+
const service = new SharpApiToursActivitiesCategoriesService(process.env.SHARP_API_KEY);
|
|
248
|
+
|
|
249
|
+
async function findSimilarActivities(referenceActivity, allActivities) {
|
|
250
|
+
// Categorize reference activity
|
|
251
|
+
const refStatusUrl = await service.categorizeProduct(referenceActivity);
|
|
252
|
+
const refResult = await service.fetchResults(refStatusUrl);
|
|
253
|
+
const refCategories = refResult.getResultJson();
|
|
254
|
+
|
|
255
|
+
const refCategoryNames = refCategories.map(c => c.name);
|
|
256
|
+
|
|
257
|
+
// Categorize all other activities and find matches
|
|
258
|
+
const scored = [];
|
|
259
|
+
for (const activity of allActivities) {
|
|
260
|
+
const statusUrl = await service.categorizeProduct(activity.description);
|
|
261
|
+
const result = await service.fetchResults(statusUrl);
|
|
262
|
+
const categories = result.getResultJson();
|
|
263
|
+
|
|
264
|
+
const activityCategories = categories.map(c => c.name);
|
|
265
|
+
const overlap = activityCategories.filter(c => refCategoryNames.includes(c));
|
|
266
|
+
const similarityScore = overlap.length / refCategoryNames.length;
|
|
267
|
+
|
|
268
|
+
if (similarityScore > 0) {
|
|
269
|
+
scored.push({
|
|
270
|
+
...activity,
|
|
271
|
+
similarityScore,
|
|
272
|
+
sharedCategories: overlap
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return scored.sort((a, b) => b.similarityScore - a.similarityScore);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const reference = 'Scuba diving with certified instructors';
|
|
281
|
+
const otherActivities = [
|
|
282
|
+
{ id: 1, description: 'Snorkeling tour in coral reef' },
|
|
283
|
+
{ id: 2, description: 'Museum guided tour' },
|
|
284
|
+
{ id: 3, description: 'Deep sea fishing adventure' }
|
|
285
|
+
];
|
|
286
|
+
|
|
287
|
+
const similar = await findSimilarActivities(reference, otherActivities);
|
|
288
|
+
console.log('Similar activities:', similar);
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Use Cases
|
|
294
|
+
|
|
295
|
+
- **Tour Booking Platforms**: Auto-categorize activity listings
|
|
296
|
+
- **Travel Marketplaces**: Organize experiences by category
|
|
297
|
+
- **Search & Filtering**: Enable category-based activity search
|
|
298
|
+
- **Recommendation Systems**: Suggest similar activities
|
|
299
|
+
- **Content Organization**: Tag and classify tour content
|
|
300
|
+
- **Dynamic Pricing**: Group activities for pricing strategies
|
|
301
|
+
- **Marketing Campaigns**: Target specific activity categories
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## Activity Categories
|
|
306
|
+
|
|
307
|
+
The system recognizes various activity types:
|
|
308
|
+
|
|
309
|
+
**Adventure & Outdoor:**
|
|
310
|
+
- Water Sports
|
|
311
|
+
- Mountain Activities
|
|
312
|
+
- Extreme Sports
|
|
313
|
+
- Wildlife Encounters
|
|
314
|
+
- Nature Tours
|
|
315
|
+
|
|
316
|
+
**Cultural & Educational:**
|
|
317
|
+
- Historical Tours
|
|
318
|
+
- Museum Visits
|
|
319
|
+
- Cooking Classes
|
|
320
|
+
- Language Learning
|
|
321
|
+
- Art Workshops
|
|
322
|
+
|
|
323
|
+
**Food & Drink:**
|
|
324
|
+
- Wine Tasting
|
|
325
|
+
- Food Tours
|
|
326
|
+
- Culinary Classes
|
|
327
|
+
- Brewery Tours
|
|
328
|
+
- Coffee Experiences
|
|
329
|
+
|
|
330
|
+
**Entertainment:**
|
|
331
|
+
- Shows & Performances
|
|
332
|
+
- Nightlife Tours
|
|
333
|
+
- Music Events
|
|
334
|
+
- Festival Access
|
|
335
|
+
- Theme Parks
|
|
336
|
+
|
|
337
|
+
**Wellness & Relaxation:**
|
|
338
|
+
- Spa Experiences
|
|
339
|
+
- Yoga Retreats
|
|
340
|
+
- Meditation Sessions
|
|
341
|
+
- Hot Springs
|
|
342
|
+
- Wellness Tours
|
|
343
|
+
|
|
344
|
+
**Transportation & Sightseeing:**
|
|
345
|
+
- City Tours
|
|
346
|
+
- Hop-On Hop-Off
|
|
347
|
+
- Scenic Drives
|
|
348
|
+
- Boat Cruises
|
|
349
|
+
- Helicopter Tours
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## API Endpoint
|
|
354
|
+
|
|
355
|
+
**POST** `/tth/ta_product_categories`
|
|
356
|
+
|
|
357
|
+
For detailed API specifications, refer to:
|
|
358
|
+
- [Postman Documentation](https://documenter.getpostman.com/view/31106842/2sBXVeGsVh)
|
|
359
|
+
- [Product Page](https://sharpapi.com/en/catalog/ai/travel-tourism-hospitality/tours-activities-product-categorization)
|
|
360
|
+
|
|
361
|
+
---
|
|
362
|
+
|
|
363
|
+
## Related Packages
|
|
364
|
+
|
|
365
|
+
- [@sharpapi/sharpapi-node-hospitality-categories](https://www.npmjs.com/package/@sharpapi/sharpapi-node-hospitality-categories) - Hospitality categorization
|
|
366
|
+
- [@sharpapi/sharpapi-node-travel-review-sentiment](https://www.npmjs.com/package/@sharpapi/sharpapi-node-travel-review-sentiment) - Review sentiment
|
|
367
|
+
- [@sharpapi/sharpapi-node-product-categories](https://www.npmjs.com/package/@sharpapi/sharpapi-node-product-categories) - General product categorization
|
|
368
|
+
- [@sharpapi/sharpapi-node-client](https://www.npmjs.com/package/@sharpapi/sharpapi-node-client) - Full SharpAPI SDK
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## License
|
|
373
|
+
|
|
374
|
+
This project is licensed under the MIT License. See the [LICENSE.md](LICENSE.md) file for details.
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
378
|
+
## Support
|
|
379
|
+
|
|
380
|
+
- **Documentation**: [SharpAPI.com Documentation](https://sharpapi.com/documentation)
|
|
381
|
+
- **Issues**: [GitHub Issues](https://github.com/sharpapi/sharpapi-node-client/issues)
|
|
382
|
+
- **Email**: contact@sharpapi.com
|
|
383
|
+
|
|
384
|
+
---
|
|
385
|
+
|
|
386
|
+
**Powered by [SharpAPI](https://sharpapi.com/) - AI-Powered API Workflow Automation**
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sharpapi/sharpapi-node-tours-activities-categories",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SharpAPI.com Node.js SDK for generating tours and activities product categories",
|
|
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
|
+
"travel",
|
|
22
|
+
"tourism",
|
|
23
|
+
"tours",
|
|
24
|
+
"activities",
|
|
25
|
+
"product categories"
|
|
26
|
+
],
|
|
27
|
+
"author": "Dawid Makowski <contact@sharpapi.com>",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@sharpapi/sharpapi-node-core": "file:../sharpapi-node-core"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"jest": "^29.7.0"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "https://github.com/sharpapi/sharpapi-node-tours-activities-categories.git"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const { SharpApiCoreService, SharpApiJobTypeEnum } = require('@sharpapi/sharpapi-node-core');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Service for generating tours and activities product categories using SharpAPI.com
|
|
5
|
+
*/
|
|
6
|
+
class SharpApiToursActivitiesCategoriesService extends SharpApiCoreService {
|
|
7
|
+
/**
|
|
8
|
+
* Generates a list of suitable categories for the Tours & Activities product
|
|
9
|
+
* with relevance weights as float value (1.0-10.0) where 10 equals 100%, the highest relevance score.
|
|
10
|
+
* Provide the product name and its parameters to get the best category matches possible.
|
|
11
|
+
* Comes in handy with populating product catalogue data and bulk product processing.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} productName
|
|
14
|
+
* @param {string|null} city
|
|
15
|
+
* @param {string|null} country
|
|
16
|
+
* @param {string|null} language
|
|
17
|
+
* @param {number|null} maxQuantity
|
|
18
|
+
* @param {string|null} voiceTone
|
|
19
|
+
* @param {string|null} context
|
|
20
|
+
* @returns {Promise<string>} - The status URL.
|
|
21
|
+
*/
|
|
22
|
+
async toursAndActivitiesProductCategories(productName, city = null, country = null, language = null, maxQuantity = null, voiceTone = null, context = null) {
|
|
23
|
+
const data = { content: productName };
|
|
24
|
+
if (city) data.city = city;
|
|
25
|
+
if (country) data.country = country;
|
|
26
|
+
if (language) data.language = language;
|
|
27
|
+
if (maxQuantity) data.max_quantity = maxQuantity;
|
|
28
|
+
if (voiceTone) data.voice_tone = voiceTone;
|
|
29
|
+
if (context) data.context = context;
|
|
30
|
+
|
|
31
|
+
const response = await this.makeRequest('POST', SharpApiJobTypeEnum.TTH_TA_PRODUCT_CATEGORIES.url, data);
|
|
32
|
+
return this.parseStatusUrl(response);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = { SharpApiToursActivitiesCategoriesService };
|