📦

JavaScript SDK

Official Node.js and browser SDK for Summize.app

Installation

Get started with the JavaScript SDK

Node.js

terminal
npm install @summize/sdk

For Node.js applications and server-side usage.

Browser

html
<script src="https://unpkg.com/@summize/sdk@latest/dist/browser.js"></script>

For browser-based applications and frontend usage.

Quick Start

Get up and running in minutes

Basic Usage

javascript
// Import the SDK
import { Summize } from '@summize/sdk';

// Initialize with your API key
const summize = new Summize('your-api-key');

// Generate a summary
const result = await summize.summarize({
  data: salesData,
  format: 'narrative',
  style: 'executive'
});

console.log(result.summary);

API Reference

Complete documentation of all methods and options

Constructor

new Summize(apiKey, options?)

Parameters

  • apiKey (string) - Your Summize API key
  • options (object, optional) - Configuration options

Options

  • baseURL - Custom API base URL
  • timeout - Request timeout in milliseconds
  • retries - Number of retry attempts

summarize(data, options?)

Generate AI-powered summaries from your data

const result = await summize.summarize(data, {
  format: 'narrative',
  style: 'executive',
  maxLength: 500
});

Parameters

  • data - Your data to summarize
  • options.format - 'narrative' | 'bullet' | 'executive'
  • options.style - 'technical' | 'business' | 'casual'
  • options.maxLength - Maximum summary length

Returns

  • summary - Generated summary text
  • insights - Array of key insights
  • confidence - Confidence score (0-1)
  • processingTime - Processing time in seconds

getReports(options?)

Retrieve generated reports and summaries

const reports = await summize.getReports({
  limit: 10,
  offset: 0,
  status: 'completed'
});

Parameters

  • options.limit - Number of reports to return
  • options.offset - Pagination offset
  • options.status - Filter by status

Returns

  • reports - Array of report objects
  • total - Total number of reports
  • hasMore - Whether more reports exist

Examples

Common use cases and patterns

Sales Data Summary

const salesData = {
  revenue: 125000,
  growth: 15.5,
  topProducts: ['Product A', 'Product B'],
  regions: ['North', 'South', 'East']
};

const summary = await summize.summarize(salesData, {
  format: 'executive',
  style: 'business'
});

console.log(summary.summary);
// "Q4 revenue reached $125K with 15.5% growth..."

Error Handling

try {
  const result = await summize.summarize(data);
  console.log(result.summary);
} catch (error) {
  if (error.code === 'RATE_LIMIT') {
    console.log('Rate limit exceeded');
  } else if (error.code === 'INVALID_API_KEY') {
    console.log('Invalid API key');
  } else {
    console.log('Unexpected error:', error.message);
  }
}

Migration Guide

Upgrading from previous versions

Version 2.0 Breaking Changes

  • • Constructor now requires API key as first parameter
  • • All methods now return Promises (async/await required)
  • • Error handling improved with specific error codes
  • • New options for better customization

Ready to get started?

Install the JavaScript SDK and start building with Summize.