🚀. Socket Launch Week Day 2:Introducing Manifest Alerts.Learn more
Sign In

@binance/types

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@binance/types

Shared types for Binance connectors

latest
npmnpm
Version
1.0.24
Version published
Weekly downloads
52
-79.61%
Maintainers
1
Weekly downloads
 
Created
Source

Binance TypeScript Types

Code Style: Prettier npm version npm Downloads Node.js Version Socket Badge License: MIT

@binance/types is a TypeScript type definition package for Binance modular connectors. It centralizes shared interfaces, types, and error classes, ensuring consistency across all Binance Connectors.

This package is designed to be used with the modular Binance connectors.

Table of Contents

Features

  • Centralized Type Definitions for Binance REST/WebSocket APIs
  • Error Classes for standardized exception handling
  • Shared Configuration Interfaces used across all Binance Connectors
  • Lightweight & Tree-Shakeable – excludes runtime values when possible
  • Fully Compatible with TypeScript for strong type safety

Installation

To use this package, install it via npm:

npm install @binance/types

Usage

This package provides types and error classes to be used within Binance Connectors.

Example: Importing Common Types

import type { ConfigurationRestAPI } from '@binance/types';

const config: ConfigurationRestAPI = {
    apiKey: 'your-api-key',
    apiSecret: 'your-api-secret',
};

Example: Handling Errors Consistently

import { ConnectorClientError, UnauthorizedError } from '@binance/types';

try {
    // Some API call
} catch (err) {
    if (err instanceof ConnectorClientError) {
        console.error('Client error occurred:', err);
    } else if (err instanceof UnauthorizedError) {
        console.error('Invalid API credentials:', err);
    } else {
        console.error('Unexpected error:', err);
    }
}

Available Types

API Response Types

  • RestApiResponse<T> – Standardized REST API response structure
  • WebsocketApiResponse<T> – WebSocket response format

Configuration Types

  • ConfigurationRestAPI – Configuration structure for REST API clients
  • ConfigurationWebsocketAPI – Configuration for WebSocket API clients
  • ConfigurationWebsocketStreams – Config for managing WebSocket streams

Rate Limit Types

  • RestApiRateLimit
  • WebsocketApiRateLimit

Error Handling

The package includes predefined error classes to simplify error handling across Binance SDKs.

Error ClassDescription
ConnectorClientErrorGeneric client error
RequiredErrorMissing required parameter
UnauthorizedErrorInvalid or missing API key
ForbiddenErrorAccess denied
TooManyRequestsErrorRate limit exceeded
RateLimitBanErrorBanned due to excessive API calls
ServerErrorInternal Binance server error
NetworkErrorNetwork connectivity issue
NotFoundErrorRequested resource not found
BadRequestErrorMalformed request

Example: Catching API Errors

import { RequiredError, NotFoundError } from '@binance/types';

try {
    // API call
} catch (err) {
    if (err instanceof RequiredError) {
        console.error('Missing required parameters:', err);
    } else if (err instanceof NotFoundError) {
        console.error('Requested resource does not exist:', err);
    }
}

Contributing

Contributions are welcome!

  • Open a GitHub issue before making changes.
  • Discuss proposed changes with maintainers.
  • Follow the existing TypeScript structure.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Keywords

Binance

FAQs

Package last updated on 02 Jun 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts