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.
- Real-time sentiment scores
- Batch processing with callbacks
- Flexible configuration
Use analyzeText()
to process a single input.
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.
- Install using a package manager
- Reference the browser bundle
- Authenticate with your API key
The SDK initialization must be completed before invoking any analysis functions.
Use initClient(config)
to begin setup.
Instantiate the client with credentials and base configuration options.
Set default language and desired thresholds for polarity classification.
- API key setup
- Language preference
- Method call and response interpretation
The sentiment result returns a value between -1
and 1
.
Use getSentiment(text)
for quick access to scores.
Main SDK methods include:
analyzeText(text, options)
– returns polarity and confidencebatchAnalyze(array, options)
– handles multiple items efficientlysetDefaultLanguage(code)
– sets fallback languageconfigureThreshold(min, max)
– customizes neutrality cutoffonError(handler)
– catches and logs errors
Each method accepts options like callbacks, language overrides, and return formats.
Configure the SDK using either global settings or local method overrides.
- Language Support – multiple locales including EN, ES, FR
- Threshold Tuning – polarity sensitivity control
- Endpoint Selection – self-hosting or cloud inference
Advanced modes allow chaining of custom plugins and batching control.
Call sdk.setConfig()
to apply runtime preferences.
Optimize performance and results quality with the following tips:
- Preprocess input: trim spaces, remove HTML
- Batch where possible: avoid throttling
- Cache identical inputs
- Monitor low-confidence outputs for accuracy
Use translateZ(0)
for GPU-accelerated rendering when combining with UI changes.
Common questions about using the SDK:
- How accurate is it?
- Best results for conversational inputs. Technical terms may reduce confidence.
- What languages are supported?
- English, Spanish, French, German, Chinese, Japanese.
- Can I send long text?
- Yes. Segmenting into chunks is recommended for faster response.
- Does it detect sarcasm?
- Detection of nuanced tone is limited. Human review is advised in edge cases.