npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sharpapi/sharpapi-node-hospitality-categories

v1.0.1

Published

SharpAPI.com Node.js SDK for generating hospitality product categories

Downloads

174

Readme

SharpAPI GitHub cover

Hospitality Product Categorization API for Node.js

🏨 Automatically categorize hospitality products with AI — powered by SharpAPI.

npm version License

SharpAPI Hospitality Product Categorization uses AI to automatically categorize hotels, resorts, vacation rentals, and other hospitality products based on their descriptions. Perfect for travel platforms, booking systems, and hospitality management tools.


📋 Table of Contents

  1. Requirements
  2. Installation
  3. Usage
  4. API Documentation
  5. Response Format
  6. Examples
  7. License

Requirements

  • Node.js >= 16.x
  • npm or yarn

Installation

Step 1. Install the package via npm:

npm install @sharpapi/sharpapi-node-hospitality-categories

Step 2. Get your API key

Visit SharpAPI.com to get your API key.


Usage

const { SharpApiHospitalityCategoriesService } = require('@sharpapi/sharpapi-node-hospitality-categories');

const apiKey = process.env.SHARP_API_KEY;
const service = new SharpApiHospitalityCategoriesService(apiKey);

const propertyDescription = `
Luxury beachfront resort with private villas, infinity pool, spa,
and fine dining restaurant. All-inclusive package available.
Perfect for romantic getaways and honeymoons.
`;

async function categorizeProperty() {
  try {
    const statusUrl = await service.categorizeProduct(propertyDescription);
    console.log('Job submitted. Status URL:', statusUrl);

    const result = await service.fetchResults(statusUrl);
    console.log('Categories:', result.getResultJson());
  } catch (error) {
    console.error('Error:', error.message);
  }
}

categorizeProperty();

API Documentation

Methods

categorizeProduct(productDescription: string, maxCategories?: number): Promise<string>

Categorizes a hospitality product based on its description.

Parameters:

  • productDescription (string, required): The property/product description to categorize
  • maxCategories (number, optional): Maximum number of categories to return (default: 5)

Returns:

  • Promise: Status URL for polling the job result

Response Format

The API returns categories with relevance scores (weight: 0-10):

{
  "categories": [
    {
      "name": "Luxury Beach Resort",
      "weight": 10,
      "subcategories": ["All-Inclusive", "Spa Resort", "Romantic Getaway"]
    },
    {
      "name": "Boutique Hotel",
      "weight": 7,
      "subcategories": ["Beachfront", "Adults Only"]
    },
    {
      "name": "Honeymoon Destination",
      "weight": 9,
      "subcategories": ["Romantic", "Luxury"]
    }
  ]
}

Weight Scale:

  • 10: Perfect match
  • 8-9: Highly relevant
  • 6-7: Moderately relevant
  • 4-5: Somewhat relevant
  • 1-3: Slightly relevant

Examples

Basic Categorization

const { SharpApiHospitalityCategoriesService } = require('@sharpapi/sharpapi-node-hospitality-categories');

const service = new SharpApiHospitalityCategoriesService(process.env.SHARP_API_KEY);

const property = 'Budget-friendly city hotel near train station with free WiFi and breakfast';

service.categorizeProduct(property)
  .then(statusUrl => service.fetchResults(statusUrl))
  .then(result => {
    const categories = result.getResultJson();
    console.log('📂 Property Categories:');
    categories.forEach((cat, index) => {
      console.log(`${index + 1}. ${cat.name} (relevance: ${cat.weight}/10)`);
      if (cat.subcategories) {
        console.log(`   Subcategories: ${cat.subcategories.join(', ')}`);
      }
    });
  })
  .catch(error => console.error('Categorization failed:', error));

Batch Property Categorization

const service = new SharpApiHospitalityCategoriesService(process.env.SHARP_API_KEY);

const properties = [
  'Mountain ski lodge with heated pool and après-ski bar',
  'Downtown business hotel with conference facilities and gym',
  'Family-friendly resort with kids club and water park',
  'Historic boutique hotel in restored Victorian mansion'
];

async function categorizeAll(properties) {
  const categorized = await Promise.all(
    properties.map(async (property) => {
      const statusUrl = await service.categorizeProduct(property, 3);
      const result = await service.fetchResults(statusUrl);
      const categories = result.getResultJson();

      return {
        property,
        primary_category: categories[0]?.name,
        all_categories: categories.map(c => c.name)
      };
    })
  );

  return categorized;
}

const results = await categorizeAll(properties);
console.log('Categorized properties:', results);

Travel Platform Integration

const service = new SharpApiHospitalityCategoriesService(process.env.SHARP_API_KEY);

async function enrichPropertyListing(property) {
  const fullDescription = `
    ${property.name}
    ${property.description}
    Amenities: ${property.amenities.join(', ')}
    Location: ${property.location}
  `;

  const statusUrl = await service.categorizeProduct(fullDescription);
  const result = await service.fetchResults(statusUrl);
  const categories = result.getResultJson();

  // Get high-relevance categories
  const primaryCategories = categories
    .filter(cat => cat.weight >= 7)
    .map(cat => cat.name);

  // Extract tags from subcategories
  const tags = categories
    .flatMap(cat => cat.subcategories || [])
    .filter((tag, index, self) => self.indexOf(tag) === index);

  return {
    ...property,
    categories: primaryCategories,
    tags: tags,
    searchable_text: [...primaryCategories, ...tags].join(' '),
    categorization_confidence: categories[0]?.weight || 0
  };
}

const property = {
  id: 'PROP-12345',
  name: 'Seaside Paradise Resort',
  description: 'Luxury oceanfront resort with private beach',
  amenities: ['Pool', 'Spa', 'Restaurant', 'Bar'],
  location: 'Cancun, Mexico'
};

const enrichedProperty = await enrichPropertyListing(property);
console.log('Enriched listing:', enrichedProperty);

Smart Search Filter Generation

const service = new SharpApiHospitalityCategoriesService(process.env.SHARP_API_KEY);

async function generateSearchFilters(propertyDescriptions) {
  const allCategories = new Map();

  for (const description of propertyDescriptions) {
    const statusUrl = await service.categorizeProduct(description);
    const result = await service.fetchResults(statusUrl);
    const categories = result.getResultJson();

    categories.forEach(cat => {
      if (!allCategories.has(cat.name)) {
        allCategories.set(cat.name, 0);
      }
      allCategories.set(cat.name, allCategories.get(cat.name) + 1);
    });
  }

  // Convert to filter options
  const filters = Array.from(allCategories.entries())
    .map(([category, count]) => ({
      value: category.toLowerCase().replace(/\s+/g, '_'),
      label: category,
      count: count
    }))
    .sort((a, b) => b.count - a.count);

  return filters;
}

const sampleDescriptions = [
  'Beach resort with water sports...',
  'Mountain lodge with skiing...',
  'City hotel with conference rooms...'
];

const searchFilters = await generateSearchFilters(sampleDescriptions);
console.log('Available search filters:', searchFilters);

Use Cases

  • Travel Booking Platforms: Auto-categorize hotel listings
  • Property Management Systems: Organize properties by type
  • Search & Discovery: Enable filtered search by category
  • Content Management: Tag and organize hospitality content
  • Recommendation Engines: Match properties to user preferences
  • Market Analysis: Analyze property types in portfolios
  • Inventory Management: Classify accommodation inventory

Hospitality Categories

The system recognizes various property types:

Accommodation Types:

  • Luxury Hotels & Resorts
  • Budget & Economy Hotels
  • Boutique Hotels
  • Business Hotels
  • Extended Stay Hotels
  • Vacation Rentals
  • Bed & Breakfast
  • Hostels

Specialized Categories:

  • Beach Resorts
  • Mountain Lodges
  • Spa Resorts
  • Golf Resorts
  • All-Inclusive Resorts
  • Family Resorts
  • Adults-Only Properties
  • Pet-Friendly Hotels

Purpose-Based:

  • Romantic Getaways
  • Business Travel
  • Family Vacations
  • Adventure Travel
  • Wellness Retreats

API Endpoint

POST /tth/hospitality_product_categories

For detailed API specifications, refer to:


Related Packages


License

This project is licensed under the MIT License. See the LICENSE.md file for details.


Support


Powered by SharpAPI - AI-Powered API Workflow Automation