Introduction

The Sentiment-Analysis SDK is a lightweight JavaScript wrapper that simplifies sentiment scoring for texts. It supports both browser and Node environments.

Built for interactive apps and large-scale data workflows, it streamlines language configuration and integrates error-handling into every analysis pipeline.

It is used in chatbots, email sentiment flagging, product review mining, and customer support routing.

Use analyzeText() to process a single input.

Installation

You can add the SDK via npm or Yarn, or use a CDN script tag for quick setup.

Verify connectivity to the sentiment model before initiating requests.

  1. Install using a package manager
  2. Reference the browser bundle
  3. Authenticate with your API key

The SDK initialization must be completed before invoking any analysis functions.

Use initClient(config) to begin setup.

Getting Started

Instantiate the client with credentials and base configuration options.

Set default language and desired thresholds for polarity classification.

  1. API key setup
  2. Language preference
  3. Method call and response interpretation

The sentiment result returns a value between -1 and 1.

Use getSentiment(text) for quick access to scores.

API Reference

Main SDK methods include:

Each method accepts options like callbacks, language overrides, and return formats.

Advanced Configuration

Configure the SDK using either global settings or local method overrides.

Advanced modes allow chaining of custom plugins and batching control.

Call sdk.setConfig() to apply runtime preferences.

Best Practices & Performance

Optimize performance and results quality with the following tips:

Use translateZ(0) for GPU-accelerated rendering when combining with UI changes.

FAQ

Common questions about using the SDK: