Docs

Installing the JavaScript/TypeScript SDK

Overview

A TypeScript/JavaScript SDK for interacting with the Sentor ML API for sentiment analysis. This SDK provides a simple and type-safe interface for sentiment analysis operations.

Features

  • 🚀 TypeScript support with full type definitions
  • ⚡ Simple and intuitive API
  • 🌍 Support for multiple languages
  • 📦 Batch processing capabilities
  • 🛡️ Comprehensive error handling
  • 🔄 Real-time sentiment analysis

Requirements

System Requirements

  • Node.js 14.x or higher
  • npm 6.x or yarn 1.22.x
  • Minimum 512MB RAM
  • Active internet connection

Supported Environments

  • Node.js
  • Browser (via bundlers)
  • React/Next.js
  • Vue.js
  • Angular

Installation

Using npm

npm install sentor-sdk

Configuration

Setup

import { SentorClient } from 'sentor-sdk';

// Initialize the client
const client = new SentorClient('your-api-key');

Usage

import { SentorClient } from 'sentor-sdk';

// Initialize the client
const client = new SentorClient('your-api-key');

// Analyze sentiment
const input = 
{
  "docs": [
    {
      "doc": "In the competitive landscape of consumer electronics, Apple and Samsung continue to lead the market with innovative products and strong brand loyalty. While Apple focuses on a tightly integrated ecosystem with devices like the iPhone, iPad, and Mac, Samsung excels in offering a wide range of options across various price points, especially in its Galaxy smartphone lineup. Both companies push the boundaries of technology, from cutting-edge chipsets to advanced camera systems, often setting industry trends that others follow.",
      "doc_id": "0",
      "entities": [
        "Apple",
        "Samsung",
        "camera"
      ]
    },
    {
      "doc": "Apple's new iPhone is amazing!",
      "doc_id": "1",
      "entities": [
        "Apple",
        "iPhone"
      ]
    },
    {
      "doc": "Samsung's new phone is amazing!",
      "doc_id": "2",
      "entities": [
        "Samsung",
        "phone"
      ]
    }
  ]
}
const result = await client.analyze(input);
console.log(result);

Environment Setup

Using Environment Variables

# .env file
SENTOR_API_KEY=your-api-key
SENTOR_ENV=production
// Load environment variables
import dotenv from 'dotenv';
dotenv.config();

const client = new SentorClient(process.env.SENTOR_API_KEY);