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

v1.0.1

Published

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

Readme

SharpAPI GitHub cover

Product Review Sentiment Analyzer API for Node.js

⭐ Analyze product review sentiment with AI — powered by SharpAPI.

npm version License

SharpAPI Product Review Sentiment Analyzer uses advanced AI to determine if product reviews are positive, negative, or neutral with confidence scores. Perfect for e-commerce platforms, review management, and customer feedback analysis.


📋 Table of Contents

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

Requirements

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

Installation

Step 1. Install the package via npm:

npm install @sharpapi/sharpapi-node-product-review-sentiment

Step 2. Get your API key

Visit SharpAPI.com to get your API key.


Usage

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

const apiKey = process.env.SHARP_API_KEY; // Store your API key in environment variables
const service = new SharpApiProductReviewSentimentService(apiKey);

const review = `
This product exceeded my expectations! The quality is outstanding and delivery was fast.
I highly recommend it to anyone looking for a reliable solution.
`;

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

    // Fetch results (polls automatically until complete)
    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 product review.

Parameters:

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

Returns:

  • Promise: Status URL for polling the job result

Example:

const statusUrl = await service.analyzeSentiment(customerReview);
const result = await service.fetchResults(statusUrl);

Response Format

The API returns sentiment classification with confidence score:

{
  "opinion": "POSITIVE",
  "score": 95,
  "key_phrases": [
    "exceeded expectations",
    "outstanding quality",
    "highly recommend"
  ]
}

Sentiment Values:

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

Examples

Basic Sentiment Analysis

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

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

const review = 'The product broke after 2 days. Very disappointed with the quality.';

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

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

const reviews = [
  { id: 1, text: 'Amazing product! Love it.' },
  { id: 2, text: 'Not worth the money, poor quality.' },
  { id: 3, text: 'Good product, fast shipping.' },
  { id: 4, text: 'Terrible experience, would not buy again.' }
];

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;

console.log(`Positive reviews: ${positive}/${analyzed.length}`);
console.log(`Negative reviews: ${negative}/${analyzed.length}`);

Product Rating Dashboard

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

async function analyzeProductReviews(productId, 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 positiveCount = sentiments.filter(s => s.opinion === 'POSITIVE').length;
  const negativeCount = sentiments.filter(s => s.opinion === 'NEGATIVE').length;
  const neutralCount = sentiments.filter(s => s.opinion === 'NEUTRAL').length;

  const avgScore = sentiments.reduce((sum, s) => sum + s.score, 0) / sentiments.length;

  return {
    productId,
    totalReviews: reviews.length,
    positive: positiveCount,
    negative: negativeCount,
    neutral: neutralCount,
    averageConfidence: Math.round(avgScore),
    overallSentiment: positiveCount > negativeCount ? 'POSITIVE' : 'NEGATIVE'
  };
}

const productReviews = [
  { text: 'Great quality, very satisfied!' },
  { text: 'Perfect for my needs.' },
  { text: 'Not as described, disappointed.' }
];

const dashboard = await analyzeProductReviews('PROD-123', productReviews);
console.log('Product Sentiment Dashboard:', dashboard);

Use Cases

  • E-commerce Platforms: Analyze customer reviews automatically
  • Review Moderation: Flag negative reviews for quick response
  • Product Insights: Understand customer satisfaction trends
  • Quality Control: Identify products with declining sentiment
  • Marketing: Highlight positive reviews in campaigns
  • Customer Support: Prioritize responses to negative feedback
  • Competitive Analysis: Compare sentiment across products

Sentiment Detection

The analyzer evaluates multiple factors:

  • Language Patterns: Positive vs negative word choices
  • Emotional Indicators: Expressions of satisfaction or frustration
  • Rating Consistency: Alignment with explicit ratings
  • Key Phrases: Important phrases indicating sentiment
  • Context Understanding: Industry-specific terminology
  • Sarcasm Detection: Identifies ironic or sarcastic reviews

API Endpoint

POST /ecommerce/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