Skip to main content

Overview

The Benzinga TypeScript/JavaScript SDK provides a modular, event-based interface for interacting with Benzinga APIs. Written in TypeScript, the SDK works seamlessly in both browser and Node.js environments, offering enhanced implementations with caching, deep comparison, and other advanced capabilities.

Key Features

  • TypeScript Support - Full TypeScript types and interfaces
  • Universal - Works in both browser and Node.js environments
  • Modular Architecture - Install only the modules you need
  • Event-Based - Reactive programming patterns for real-time data
  • Advanced Features - Built-in caching, deep comparison, and optimizations
  • Modern - ES6+ syntax with async/await support

Requirements

  • Node.js 14 or newer

Installation

The SDK uses a modular architecture. Start by installing the core session module:
Then install additional modules as needed:

Getting Started

Session Setup

The @benzinga/session module provides the foundation for authenticating with Benzinga APIs. All other modules depend on this Session object.

Configuration Options

The Session object accepts various configuration options for customizing behavior:

Core Concepts

Modular Design

Each Benzinga API domain is packaged as a separate npm module. This allows you to:
  • Install only what you need
  • Reduce bundle size
  • Maintain clear separation of concerns
  • Update modules independently

Event-Based Architecture

The SDK uses an event-driven pattern for handling real-time data streams and updates:

Caching & Performance

The SDK includes built-in caching mechanisms to:
  • Reduce unnecessary API calls
  • Improve response times
  • Optimize bandwidth usage
  • Provide offline fallbacks

Deep Comparison

Advanced data comparison features enable:
  • Detecting changes in nested objects
  • Efficient state management
  • Smart update triggers
  • Reduced re-renders in UI applications

Available Modules

The SDK is organized into focused modules for different API domains:

Core Modules

  • @benzinga/session - Authentication and session management (required)
  • @benzinga/calendar-data - Calendar events and corporate actions
  • @benzinga/news-data - News articles and market intelligence
  • @benzinga/quotes - Real-time and delayed quotes
  • @benzinga/fundamentals - Company fundamentals and financial data

Specialized Modules

  • @benzinga/ratings - Analyst ratings and price targets
  • @benzinga/options - Options activity and analytics
  • @benzinga/transcripts - Earnings call transcripts
  • @benzinga/logos - Company logos and branding
  • @benzinga/signals - Trading signals and indicators

TypeScript Support

The SDK is written in TypeScript and provides full type definitions:

Usage Examples

Basic Data Fetching

Real-Time Data Streams

Calendar Events

Company Fundamentals

Browser Usage

The SDK works in browser environments with bundlers like Webpack, Rollup, or Vite:

Error Handling

Handle errors gracefully with try-catch blocks:

Pagination

Handle paginated results efficiently:

Caching Strategy

Leverage the built-in caching for better performance:

Best Practices

1. Reuse Session Objects

Create one session instance and reuse it across your application:

2. Environment Variables

Store API keys securely in environment variables:

3. Type Safety

Leverage TypeScript for type-safe API interactions:

4. Error Boundaries

Implement error boundaries in production:

Resources

Module Documentation

For detailed documentation on specific modules, refer to the individual package READMEs:
  • @benzinga/session - Core authentication and configuration
  • @benzinga/calendar-data - Calendar events API
  • @benzinga/news-data - News and articles API
  • @benzinga/quotes - Real-time quotes API
  • @benzinga/fundamentals - Fundamentals and financials API

Support

For technical support and API key provisioning, contact Benzinga at cloud.benzinga.com.

Contributing

The Benzinga JavaScript SDK is open source. Contributions are welcome! Visit the GitHub repository for more information.