@marlo-cloud/sentiment-client
v1.0.4
Published
JavaScript/TypeScript client for Marlo sentiment analysis API
Maintainers
Readme
@marlo-cloud/sentiment-client
JavaScript/TypeScript client for the Marlo sentiment analysis API.
Installation
npm install @marlo-cloud/sentiment-clientUsage
Basic Usage
import { MarloClient } from '@marlo-cloud/sentiment-client';
const client = new MarloClient({
apiKey: 'your-rapidapi-key'
});
// Analyze text sentiment
const result = await client.analyze('I love this product!');
console.log(result);
// {
// sentiment: 'positive',
// confidence: 0.9162,
// scores: {
// positive: 0.647,
// neutral: 0.353,
// negative: 0.0,
// compound: 0.9162
// },
// text_length: 20
// }Industry-Specific Analysis
// Healthcare context
const healthcareResult = await client.analyze(
'Strong medication led to successful treatment',
'healthcare'
);
// Gaming context
const gamingResult = await client.analyze(
'Epic gameplay but pay-to-win ruins it',
'gaming'
);
// Technology context
const techResult = await client.analyze(
'Memory leak in the application',
'technology'
);Batch Analysis
const texts = [
'Great customer service!',
'Product arrived damaged',
'Fast shipping, excellent quality'
];
const results = await client.batchAnalyze(texts, 'retail');Supported Industries
const industries = client.getSupportedIndustries();
console.log(industries);
// ['healthcare', 'technology', 'gaming', 'finance', 'restaurant',
// 'automotive', 'real_estate', 'fitness', 'education', 'retail']Configuration Options
const client = new MarloClient({
apiKey: 'your-rapidapi-key',
baseUrl: 'https://custom-endpoint.com', // optional
timeout: 5000 // optional, default 10000ms
});Error Handling
import { MarloClient, MarloError } from '@marlo-cloud/sentiment-client';
try {
const result = await client.analyze('');
} catch (error) {
if (error instanceof MarloError) {
console.log(`Error ${error.statusCode}: ${error.message}`);
}
}TypeScript Support
Full TypeScript support with detailed type definitions:
import { MarloClient, SentimentResponse, Industry } from '@marlo-cloud/sentiment-client';
const client = new MarloClient({ apiKey: 'your-key' });
const result: SentimentResponse = await client.analyze('text', 'healthcare' as Industry);Resources
- Marlo API Documentation - Complete API guide and examples
- npm Package - Install via npm
- GitHub Repository - Source code and issues
- Support - Get help and contact support
License
MIT
