
Official Node.js SDK for Fluxum API
Get up and running with the Fluxum Node.js SDK in minutes
npm install fluxum-sdk-nodeyarn add fluxum-sdk-nodeBuilt specifically for Node.js with event-driven architecture and async/await support.
Built-in client-side encryption with optional custom encryption keys for maximum security.
Comprehensive analytics tracking for connections, jobs, and rate limits with Node.js streams.
Handle real-time events with the SDK
// Connection events
sdk.on('connected', () => {
console.log('WebSocket connected');
});
sdk.on('authenticated', (data) => {
console.log('Authentication successful', data.clientId);
});
sdk.on('disconnected', (data) => {
console.log('Disconnected:', data.reason, data.code);
});
// Job events
sdk.on('jobSubmitted', (data) => {
console.log('Job submitted:', data.jobId);
});
sdk.on('jobAccepted', (data) => {
console.log('Job accepted:', data.jobId);
});
sdk.on('jobUpdate', (update) => {
console.log('Job update:', update.jobId, update.status);
});
// Error handling
sdk.on('error', (error) => {
console.log('SDK Error:', error.message);
});
// Rate limiting
sdk.on('rateLimitStatus', (status) => {
console.log('Rate limit:', status.isRateLimited);
});Examples of different job types and configurations
const job = {
targetUrl: 'https://api.example.com/data',
method: 'GET',
headers: {
'Authorization': 'Bearer your-token'
}
};
const jobId = await sdk.submitJob(job);const job = {
targetUrl: 'https://api.example.com/users',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer your-token'
},
body: JSON.stringify({
name: 'John Doe',
email: '[email protected]'
})
};
const jobId = await sdk.submitJob(job);const job = {
targetUrl: 'https://api.example.com/upload',
method: 'POST',
headers: {
'Content-Type': 'multipart/form-data'
},
body: formData // FormData object
};
const jobId = await sdk.submitJob(job);Advanced configuration and features
const sdk = new FluxumSDK({
apiKey: 'your-api-key',
enableClientSideEncryption: true,
encryptionKey: 'your-custom-encryption-key'
});// Manual connection
await sdk.connect();
// Disconnect
await sdk.disconnect();
// Check connection status
if (sdk.isConnected()) {
console.log('Connected');
}
// Reconnect
await sdk.reconnect();// Get analytics data
const analytics = sdk.getAnalytics();
console.log('Total jobs:', analytics.totalJobs);
console.log('Successful jobs:', analytics.successfulJobs);
console.log('Failed jobs:', analytics.failedJobs);
console.log('Average response time:', analytics.averageResponseTime);
// Reset analytics
sdk.resetAnalytics();Comprehensive error handling and recovery
// Global error handler
sdk.on('error', (error) => {
switch (error.type) {
case 'connection':
console.error('Connection error:', error.message);
break;
case 'authentication':
console.error('Authentication error:', error.message);
break;
case 'job':
console.error('Job error:', error.message);
break;
case 'rate_limit':
console.error('Rate limit exceeded:', error.message);
break;
default:
console.error('Unknown error:', error.message);
}
});
// Handle specific errors
sdk.on('connectionFailed', (error) => {
console.error('Failed to connect:', error.message);
// Implement retry logic
});
sdk.on('authenticationFailed', (error) => {
console.error('Authentication failed:', error.message);
// Handle invalid API key
});System requirements and dependencies
Node.js 18.0.0 or higher
Complete API documentation
new FluxumSDK(options: {
apiKey: string;
autoConnect?: boolean;
enableClientSideEncryption?: boolean;
enableAnalytics?: boolean;
maxReconnectAttempts?: number;
reconnectDelay?: number;
connectionTimeout?: number;
logLevel?: 'debug' | 'info' | 'warn' | 'error';
})// Connection
await sdk.connect(): Promise<void>
await sdk.disconnect(): Promise<void>
await sdk.reconnect(): Promise<void>
// Status
sdk.isConnected(): boolean
sdk.isAuthenticated(): boolean
// Jobs
await sdk.submitJob(job: JobConfig): Promise<string>
await sdk.cancelJob(jobId: string): Promise<void>
// Analytics
sdk.getAnalytics(): AnalyticsData
sdk.resetAnalytics(): void
// Events
sdk.on(event: string, callback: Function): void
sdk.off(event: string, callback: Function): void