JavaScript SDK
Build intelligent applications with our official JavaScript client library
Installation
Install the WebburnsTech JavaScript SDK using npm or yarn to get started quickly.
npm install @webburnstech/sdk
yarn add @webburnstech/sdk
<script src="https://unpkg.com/@webburnstech/sdk@latest/dist/webburnstech.min.js"></script>
Quick Start
Initialize the SDK with your API key and start making requests in seconds.
import { WebburnsTech } from '@webburnstech/sdk';
// Initialize the client
const client = new WebburnsTech({
apiKey: 'your-api-key-here', // Get from https://dashboard.webburnstech.dev
environment: 'production' // or 'development' for testing
});
// Make your first API call
async function analyzeSentiment() {
try {
const response = await client.nlp.analyzeSentiment({
text: 'WebburnsTech makes AI integration incredibly simple!',
language: 'en'
});
console.log('Sentiment:', response.sentiment); // 'positive'
console.log('Confidence:', response.confidence); // 0.95
console.log('Emotions:', response.emotions); // { joy: 0.8, ... }
} catch (error) {
console.error('Error:', error.message);
}
}
analyzeSentiment();
API Reference
Explore the complete JavaScript SDK API with detailed examples for each method.
Natural Language Processing
Process and understand human language with our advanced NLP models.
Analyze the sentiment and emotional tone of text.
const response = await client.nlp.analyzeSentiment({
text: 'I absolutely love this product! It has changed my workflow completely.',
language: 'en', // optional, auto-detected if not provided
detailed: true // optional, returns emotion breakdown
});
// Response:
{
sentiment: 'positive',
confidence: 0.92,
emotions: {
joy: 0.85,
trust: 0.78,
anticipation: 0.64
}
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| text | string | Yes | The text to analyze for sentiment |
| language | string | No | Language code (e.g., 'en', 'es', 'fr'). Auto-detected if not provided. |
| detailed | boolean | No | Whether to return detailed emotion analysis |
Extract named entities (people, organizations, locations) from text.
const response = await client.nlp.extractEntities({
text: 'Apple Inc. was founded by Steve Jobs in Cupertino, California.',
types: ['PERSON', 'ORGANIZATION', 'LOCATION'] // optional filter
});
// Response:
{
entities: [
{
text: 'Apple Inc.',
type: 'ORGANIZATION',
confidence: 0.98
},
{
text: 'Steve Jobs',
type: 'PERSON',
confidence: 0.95
},
{
text: 'Cupertino',
type: 'LOCATION',
confidence: 0.92
},
{
text: 'California',
type: 'LOCATION',
confidence: 0.96
}
]
}
Computer Vision
Analyze and understand visual content with our computer vision models.
Analyze images for objects, scenes, and visual content.
// From URL
const response = await client.vision.analyzeImage({
image: 'https://example.com/image.jpg',
features: ['objects', 'faces', 'text'] // optional
});
// From file upload (browser)
const fileInput = document.getElementById('image-upload');
const file = fileInput.files[0];
const response = await client.vision.analyzeImage({
image: file,
features: ['objects', 'colors']
});
// Response:
{
objects: [
{ label: 'person', confidence: 0.95, box: [x, y, w, h] },
{ label: 'laptop', confidence: 0.87, box: [x, y, w, h] }
],
faces: [
{ age: 25, gender: 'female', emotions: { happy: 0.8 } }
],
colors: {
dominant: '#4A90E2',
palette: ['#4A90E2', '#FFFFFF', '#333333']
},
text: 'Hello World'
}
Chat & Conversations
Build intelligent conversational interfaces with our chat API.
Start a new conversation with context and personality settings.
const conversation = await client.chat.createConversation({
context: 'You are a helpful customer support assistant for a tech company.',
personality: 'friendly', // 'professional', 'casual', 'humorous'
memory: true // remember conversation history
});
const response = await conversation.sendMessage(
'How do I reset my password?'
);
// Response:
{
message: 'To reset your password, please visit our password reset page at...',
conversationId: 'conv_123',
suggestions: [
'Account settings',
'Security options',
'Contact support'
]
}
Advanced Usage
Learn about advanced features and configuration options.
Error Handling
Proper error handling for robust applications.
try {
const response = await client.nlp.analyzeSentiment({
text: 'Sample text'
});
} catch (error) {
if (error.code === 'RATE_LIMIT_EXCEEDED') {
console.log('Rate limit exceeded. Please try again later.');
} else if (error.code === 'INVALID_API_KEY') {
console.log('Invalid API key. Please check your configuration.');
} else if (error.code === 'INSUFFICIENT_CREDITS') {
console.log('Insufficient credits. Please upgrade your plan.');
} else {
console.log('An unexpected error occurred:', error.message);
}
}
Configuration Options
Customize the SDK behavior with various configuration options.
const client = new WebburnsTech({
apiKey: 'your-api-key-here',
// Configuration options
environment: 'production', // 'production' or 'development'
timeout: 30000, // request timeout in milliseconds
maxRetries: 3, // automatic retry attempts
baseURL: 'https://api.webburnstech.dev/v1', // custom API endpoint
// Request logging
debug: false, // enable debug logging
// Custom headers
headers: {
'X-Custom-Header': 'value'
},
// HTTP agent configuration (Node.js only)
httpAgent: new http.Agent({ keepAlive: true })
});
Examples & Tutorials
Explore practical examples and tutorials to get started quickly.
Sentiment Analysis Dashboard
Build a real-time sentiment analysis dashboard for customer feedback.
View Tutorial →Image Moderation System
Create an automated image moderation system using computer vision.
View Tutorial →Chatbot Integration
Integrate intelligent chatbots into your website or application.
View Tutorial →If you encounter any issues or have questions about the JavaScript SDK, check out our FAQ or join our community forum for support.