@binance/convert

中文文档
6.0.8发布于 2026/10/23MITTypeScriptESM + CJS近 30 天下载 3075

Official Binance Convert Connector - A lightweight library that provides a convenient interface to Binance's Convert REST API.

原始使用文档
文档目录10 节
  1. Table of Contents
  2. Supported Features
  3. Installation
  4. Documentation
  5. REST APIs
  6. Testing
  7. Migration Guide
  8. Contributing
  9. Disclaimer
  10. Licence

Binance JavaScript Convert Connector

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

This is a client library for the Binance Convert API, enabling developers to interact programmatically with Binance's Convert trading platform. The library provides tools to buy or sell cryptocurrencies through the REST API:

Table of Contents

Supported Features

  • REST API Endpoints:
    • /sapi/v1/convert/*
  • Inclusion of test cases and examples for quick onboarding.

Installation

To use this library, ensure your environment is running Node.js version 22.12.0 or later. If you're using nvm (Node Version Manager), you can set the correct version as follows:

nvm install 22.12.0
nvm use 22.12.0

Then install the library using npm:

npm install @binance/convert

Documentation

For detailed information, refer to the Binance API Documentation.

REST APIs

All REST API endpoints are available through the rest-api module. Note that some endpoints require authentication using your Binance API credentials.

import { Convert, ConvertRestAPI } from '@binance/convert';

const configurationRestAPI = {
    apiKey: 'your-api-key',
    apiSecret: 'your-api-secret',
};
const client = new Convert({ configurationRestAPI });

client.restAPI
    .listAllConvertPairs()
    .then((res) => res.data())
    .then((data: ConvertRestAPI.ListAllConvertPairsResponse) => console.log(data))
    .catch((err) => console.error(err));

More examples can be found in the examples/rest-api folder.

Configuration Options

The REST API supports the following advanced configuration options:

  • timeout: Timeout for requests in milliseconds (default: 1000 ms).
  • proxy: Proxy configuration:
    • host: Proxy server hostname.
    • port: Proxy server port.
    • protocol: Proxy protocol (http or https).
    • auth: Proxy authentication credentials:
      • username: Proxy username.
      • password: Proxy password.
  • keepAlive: Enable HTTP keep-alive (default: true).
  • compression: Enable response compression (default: true).
  • retries: Number of retry attempts for failed requests (default: 3).
  • backoff: Delay in milliseconds between retries (default: 1000 ms).
  • httpsAgent: Custom HTTPS agent for advanced TLS configuration.
  • privateKey: RSA or ED25519 private key for authentication.
  • privateKeyPassphrase: Passphrase for the private key, if encrypted.
Timeout

You can configure a timeout for requests in milliseconds. If the request exceeds the specified timeout, it will be aborted. See the Timeout example for detailed usage.

Proxy

The REST API supports HTTP/HTTPS proxy configurations. See the Proxy example for detailed usage.

Keep-Alive

Enable HTTP keep-alive for persistent connections. See the Keep-Alive example for detailed usage.

Compression

Enable or disable response compression. See the Compression example for detailed usage.

Retries

Configure the number of retry attempts and delay in milliseconds between retries for failed requests. See the Retries example for detailed usage.

HTTPS Agent

Customize the HTTPS agent for advanced TLS configurations. See the HTTPS Agent example for detailed usage.

Key Pair Based Authentication

The REST API supports key pair-based authentication for secure communication. You can use RSA or ED25519 keys for signing requests. See the Key Pair Based Authentication example for detailed usage.

Certificate Pinning

To enhance security, you can use certificate pinning with the httpsAgent option in the configuration. This ensures the client only communicates with servers using specific certificates. See the Certificate Pinning example for detailed usage.

Error Handling

The REST API provides detailed error types to help you handle issues effectively:

  • ConnectorClientError: General client error.
  • RequiredError: Thrown when a required parameter is missing.
  • UnauthorizedError: Indicates missing or invalid authentication credentials.
  • ForbiddenError: Access to the requested resource is forbidden.
  • TooManyRequestsError: Rate limit exceeded.
  • RateLimitBanError: IP address banned for exceeding rate limits.
  • ServerError: Internal server error.
  • NetworkError: Issues with network connectivity.
  • NotFoundError: Resource not found.
  • BadRequestError: Invalid request.

See the Error Handling example for detailed usage.

If basePath is not provided, it defaults to https://api.binance.com.

Testing

To run the tests:

npm install

npm run test

The tests cover:

  • REST API endpoints
  • Error handling and edge cases

Migration Guide

If you are upgrading to the new modularized structure, refer to the Migration Guide for detailed steps.

Contributing

Contributions are welcome!

Since this repository contains auto-generated code, we encourage you to start by opening a GitHub issue to discuss your ideas or suggest improvements. This helps ensure that changes align with the project's goals and auto-generation processes.

To contribute:

  1. Open a GitHub issue describing your suggestion or the bug you've identified.
  2. If it's determined that changes are necessary, the maintainers will merge the changes into the main branch.

Please ensure that all tests pass if you're making a direct contribution. Submit a pull request only after discussing and confirming the change.

Thank you for your contributions!

Disclaimer

This SDK is provided by Binance on an "as is" and "as available" basis for use at your own risk. Binance makes no representations or warranties of any kind, whether express or implied, as to the operation of the SDK, its accuracy, reliability, completeness, or fitness for any particular purpose.

To the fullest extent permitted by law, Binance shall not be liable for any losses, damages, or expenses of any kind arising from or in connection with your use of, or inability to use, this SDK, including but not limited to any financial losses resulting from errors, bugs, interruptions, or inaccuracies in the SDK.

Your use of this SDK to access the Binance Platform is subject to the Binance API Key Terms and the Binance Terms of Use, which shall prevail in the event of any conflict with this disclaimer. You are solely responsible for any orders or transactions executed through the Binance Platform using this SDK.

This SDK is not intended to constitute investment advice or a recommendation to buy, sell, or hold any digital asset. You should independently evaluate and verify all information before acting.

Licence

This project is licensed under the MIT License. See the LICENCE file for details.

版本与发布记录

@binance/convert 共发布 44 个版本,首次发布于 2025/03/24;过去 12 个月发布了 30 个版本。

版本发布日期距今
6.0.8latest2026/10/2316 天前
6.0.72026/10/1919 天前
6.0.62026/10/1523 天前
6.0.52026/10/021 个月前
6.0.42026/09/111 个月前
6.0.32026/09/032 个月前

关于 @binance/convert 的常见问题

@binance/convert 是什么?

Official Binance Convert Connector - A lightweight library that provides a convenient interface to Binance's Convert REST API.

如何安装 @binance/convert?

在项目目录运行 npm install @binance/convert,或使用 pnpm add / yarn add / bun add。

@binance/convert 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@binance/convert 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@binance/convert 可以商用吗?

@binance/convert 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@binance/convert 的下载量有多少?

根据 npm 官方下载统计,@binance/convert 在 2026/10/08 – 2026/11/06 这 30 天内被下载 3,075 次,日均约 103 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@binance/convert 还在维护吗?

最新版本 6.0.8 发布于 2026/10/23(16 天前);至今共发布 44 个版本,其中过去 12 个月发布了 30 个;首次发布于 2025/03/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。