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-travel-review-sentiment

v1.0.1

Published

SharpAPI.com Node.js SDK for analyzing travel review sentiment

Readme

SharpAPI GitHub cover

Travel Review Sentiment Analyzer API for Node.js

✈️ Analyze travel review sentiment with AI — powered by SharpAPI.

npm version License

SharpAPI Travel Review Sentiment Analyzer uses AI to determine if travel reviews are positive, negative, or neutral with confidence scores. Perfect for hotels, airlines, tour operators, and travel booking platforms.


📋 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-travel-review-sentiment

Step 2. Get your API key

Visit SharpAPI.com to get your API key.


Usage

const { SharpApiTravelReviewSentimentService } = require('@sharpapi/sharpapi-node-travel-review-sentiment');

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

const review = `
Amazing hotel! The staff was incredibly friendly and helpful.
The room was spacious and clean with a beautiful ocean view.
Would definitely recommend and stay here again!
`;

async function analyzeReview() {
  try {
    const statusUrl = await service.analyzeSentiment(review);
    console.log('Job submitted. Status URL:', statusUrl);

    const result = await service.fetchResults(statusUrl);
    const sentiment = result.getResultJson();

    console.log('Sentiment:', sentiment.opinion);
    console.log('Confidence:', sentiment.score + '%');
  } catch (error) {
    console.error('Error:', error.message);
  }
}

analyzeReview();

API Documentation

Methods

analyzeSentiment(reviewText: string): Promise<string>

Analyzes the sentiment of a travel review.

Parameters:

  • reviewText (string, required): The travel review text to analyze

Returns:

  • Promise: Status URL for polling the job result

Response Format

The API returns sentiment classification with confidence score:

{
  "opinion": "POSITIVE",
  "score": 95,
  "key_aspects": {
    "service": "positive",
    "cleanliness": "positive",
    "location": "positive",
    "value": "neutral"
  },
  "summary": "Highly positive review praising staff, room quality, and views"
}

Sentiment Values:

  • POSITIVE: Review expresses satisfaction or praise
  • NEGATIVE: Review expresses dissatisfaction or criticism
  • NEUTRAL: Review is balanced or factual without strong opinion

Confidence Score:

  • 90-100%: Very high confidence
  • 75-89%: High confidence
  • 60-74%: Moderate confidence
  • Below 60%: Low confidence (review may be ambiguous)

Examples

Basic Sentiment Analysis

const { SharpApiTravelReviewSentimentService } = require('@sharpapi/sharpapi-node-travel-review-sentiment');

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

const review = 'The hotel location was great but the room was dirty and noisy.';

service.analyzeSentiment(review)
  .then(statusUrl => service.fetchResults(statusUrl))
  .then(result => {
    const sentiment = result.getResultJson();

    const emoji = sentiment.opinion === 'POSITIVE' ? '😊' :
                  sentiment.opinion === 'NEGATIVE' ? '😞' : '😐';

    console.log(`${emoji} Sentiment: ${sentiment.opinion} (${sentiment.score}% confidence)`);
  })
  .catch(error => console.error('Analysis failed:', error));

Batch Review Analysis for Hotels

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

const hotelReviews = [
  { id: 1, text: 'Perfect location! Walking distance to everything.' },
  { id: 2, text: 'Terrible experience. Would not recommend.' },
  { id: 3, text: 'Average hotel. Nothing special but decent value.' },
  { id: 4, text: 'Outstanding service! Best vacation ever!' }
];

async function analyzeAllReviews(reviews) {
  const analyzed = await Promise.all(
    reviews.map(async (review) => {
      const statusUrl = await service.analyzeSentiment(review.text);
      const result = await service.fetchResults(statusUrl);
      const sentiment = result.getResultJson();

      return {
        id: review.id,
        text: review.text,
        sentiment: sentiment.opinion,
        score: sentiment.score
      };
    })
  );

  const positive = analyzed.filter(r => r.sentiment === 'POSITIVE').length;
  const negative = analyzed.filter(r => r.sentiment === 'NEGATIVE').length;
  const neutral = analyzed.filter(r => r.sentiment === 'NEUTRAL').length;

  return {
    total: reviews.length,
    positive,
    negative,
    neutral,
    positiveRate: Math.round((positive / reviews.length) * 100),
    reviews: analyzed
  };
}

const analysis = await analyzeAllReviews(hotelReviews);

console.log('📊 Review Analysis Summary:');
console.log(`Total Reviews: ${analysis.total}`);
console.log(`Positive: ${analysis.positive} (${analysis.positiveRate}%)`);
console.log(`Negative: ${analysis.negative}`);
console.log(`Neutral: ${analysis.neutral}`);

Real-time Review Monitoring

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

async function monitorReview(review, alertThreshold = 40) {
  const statusUrl = await service.analyzeSentiment(review.text);
  const result = await service.fetchResults(statusUrl);
  const sentiment = result.getResultJson();

  const alert = {
    reviewId: review.id,
    sentiment: sentiment.opinion,
    score: sentiment.score,
    needsAttention: sentiment.opinion === 'NEGATIVE' && sentiment.score >= 70,
    needsResponse: sentiment.opinion === 'NEGATIVE' && sentiment.score >= 85,
    priority: sentiment.opinion === 'NEGATIVE' ?
              (sentiment.score >= 85 ? 'HIGH' :
               sentiment.score >= 70 ? 'MEDIUM' : 'LOW') :
              'NONE'
  };

  if (alert.needsResponse) {
    console.log(`🚨 URGENT: Negative review detected (${alert.score}%)`);
    console.log(`   Review ID: ${alert.reviewId}`);
    console.log(`   Action: Immediate response required`);
  } else if (alert.needsAttention) {
    console.log(`⚠️  WARNING: Negative feedback detected`);
    console.log(`   Review ID: ${alert.reviewId}`);
    console.log(`   Action: Manager review recommended`);
  }

  return alert;
}

const newReview = {
  id: 'REV-12345',
  text: 'Absolutely terrible. The worst hotel experience ever. Staff was rude and unprofessional.'
};

const alert = await monitorReview(newReview);

Travel Platform Dashboard

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

async function generatePropertyInsights(propertyId, reviews) {
  const sentiments = await Promise.all(
    reviews.map(async (review) => {
      const statusUrl = await service.analyzeSentiment(review.text);
      const result = await service.fetchResults(statusUrl);
      return result.getResultJson();
    })
  );

  const positive = sentiments.filter(s => s.opinion === 'POSITIVE');
  const negative = sentiments.filter(s => s.opinion === 'NEGATIVE');
  const avgScore = sentiments.reduce((sum, s) => sum + s.score, 0) / sentiments.length;

  return {
    propertyId,
    totalReviews: reviews.length,
    sentimentBreakdown: {
      positive: positive.length,
      negative: negative.length,
      neutral: sentiments.length - positive.length - negative.length
    },
    averageConfidence: Math.round(avgScore),
    overallRating: positive.length > negative.length ? 'Positive' : 'Negative',
    needsImprovement: negative.length > reviews.length * 0.3,
    recommendation: negative.length > reviews.length * 0.5 ?
      'Critical: Immediate action required' :
      negative.length > reviews.length * 0.3 ?
      'Warning: Address customer concerns' :
      'Good: Maintain current service levels'
  };
}

const propertyReviews = [
  { text: 'Excellent experience!' },
  { text: 'Good value for money.' },
  { text: 'Room was dirty and outdated.' }
];

const insights = await generatePropertyInsights('HOTEL-789', propertyReviews);
console.log('Property Insights:', insights);

Use Cases

  • Hotel Management: Monitor guest satisfaction in real-time
  • Online Travel Agencies: Filter and display reviews by sentiment
  • Tour Operators: Track customer experience across tours
  • Airlines: Analyze passenger feedback and service quality
  • Restaurant Reviews: Understand diner satisfaction trends
  • Reputation Management: Identify and respond to negative feedback quickly
  • Competitive Analysis: Compare sentiment across properties

Travel-Specific Sentiment Analysis

The analyzer evaluates travel-specific factors:

  • Service Quality: Staff friendliness, professionalism
  • Cleanliness: Room and facility cleanliness
  • Location: Accessibility, convenience, safety
  • Value for Money: Price vs. quality perception
  • Amenities: Facilities and services quality
  • Food & Beverage: Dining experience
  • Comfort: Room comfort, noise levels
  • Overall Experience: General satisfaction level

API Endpoint

POST /tth/review_sentiment

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