JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 59
  • Score
    100M100P100Q70154F
  • License MIT

A TypeScript SDK with client and server routes.

Package Exports

  • aex-sdk
  • aex-sdk/client
  • aex-sdk/client-components
  • aex-sdk/server
  • aex-sdk/server-common
  • aex-sdk/server-libraries
  • aex-sdk/server-libraries-binance
  • aex-sdk/server-libraries-bitget
  • aex-sdk/server-libraries-bybit
  • aex-sdk/server-libraries-mexc

Readme

AEX SDK

npm version License: MIT TypeScript React

A comprehensive TypeScript SDK designed to interact with various cryptocurrency exchange APIs, providing both client-side components (built with React) and server-side utilities.

Features

  • Multi-Exchange Support: Currently supports Binance, Bitget, Bybit, and MEXC APIs.
  • Modular Design: Offers subroutes for importing specific functionalities:
    • aex-sdk: Main entry point for core utilities.
    • aex-sdk/client: Client-side React components.
    • aex-sdk/client/components: Specific React UI components.
    • aex-sdk/server: Server-side libraries and utilities.
    • aex-sdk/server/libraries/binance: Dedicated functions for interacting with the Binance API.
    • aex-sdk/server/libraries/bitget: Comprehensive wrapper for Bitget API functionalities.
  • TypeScript First: Built with TypeScript for excellent type safety and developer experience.
  • React Components: Includes pre-built React UI components for easy integration into React applications.
  • Server-Side Libraries: Provides robust server-side functions for interacting with exchange APIs.
  • Promise-Based: Utilizes Promises for asynchronous operations.
  • Error Handling: Includes basic error handling for API requests.
  • Environment Variable Configuration: Leverages dotenv for managing API keys and secrets.

Installation

You can install the AEX SDK using npm:

npm install aex-sdk

or yarn:

yarn add aex-sdk

Usage

Here are some basic usage examples:

Importing the main SDK:

import { /* someCoreFunction */ } from 'aex-sdk';

Importing React components:

import { MyButton } from 'aex-sdk/client/components';
function App() {
  return <MyButton label="Click Me" />;
}

Importing server-side Binance utilities:

import { getBinanceTicker } from 'aex-sdk/server/libraries/binance';

async function fetchTicker() {
  const ticker = await getBinanceTicker('BTCUSDT');
  console.log(ticker);
}

fetchTicker();

Importing server-side Bitget utilities:

import { getBitgetTicker } from 'aex-sdk/server/libraries/bitget';

async function fetchTicker() {
  try {
    const ticker = await getBitgetTicker({ symbol: "BTCUSDT" });
    console.log("Ticker Data:", ticker);
  } catch (error) {
    console.error("Error fetching ticker:", error);
  }
}

fetchTicker();

Server-Side Exchange Interaction:

The server-side libraries provide functions to interact with the APIs of supported exchanges. You'll need to configure your API keys and secrets using .env files in your server environment.

.env (example for Binance)

BINANCE_API_KEY=YOUR_BINANCE_API_KEY
BINANCE_API_SECRET=YOUR_BINANCE_API_SECRET
BINANCE_TESTNET_API_KEY=YOUR_BINANCE_TESTNET_API_KEY
BINANCE_TESTNET_API_SECRET=YOUR_BINANCE_TESTNET_API_SECRET

Refer to the specific files in the src/server/libraries directory for available functions for each exchange (Binance, Bitget, Bybit, MEXC).

.env sample

BYBIT_API_KEY=
BYBIT_API_SECRET=

BYBIT_USE_TESTNET=true
BYBIT_TESTNET_API_KEY=
BYBIT_TESTNET_API_SECRET=

BINANCE_API_KEY=
BINANCE_API_SECRET=

BINANCE_USE_TESTNET=true
BINANCE_TESTNET_API_KEY=
BINANCE_TESTNET_API_SECRET=

MEXC_API_KEY=
MEXC_API_SECRET=

BITGET_API_KEY=
BITGET_API_SECRET=
BITGET_API_PASS=

RECV_WINDOW=20000

AEX Bitget Library

This library provides a comprehensive wrapper around the Bitget API, enabling seamless interaction with the Bitget cryptocurrency exchange. It includes functionality for account management, market data retrieval, order management, and more.

Features

1. Client Initialization

  • fetchBitgetClient: Creates and returns a RestClientV2 instance for interacting with the Bitget API.
  • Automatically loads API credentials from the .env file.
  • Validates the presence of required API keys and secrets.

2. Market Data

  • getBitgetTicker: Retrieves the ticker price for a given symbol or all symbols.
  • getBitgetMarketDepth: Fetches the order book (market depth) for a specific symbol.
  • getBitgetTradeHistory: Retrieves the trade history for a given symbol.

3. Account Management

  • getBitgetAccount: Retrieves account information, including balances and account type.
  • getBitgetAccountBalance: Fetches the account balance for all supported assets.

4. Deposit and Withdrawal

  • getBitgetDepositAddress: Retrieves the deposit address for a specific coin and network.
  • getBitgetWithdrawHistory: Fetches the withdrawal history for a specific coin.

5. Order Management

  • createBitgetOrder: Creates a new order (market or limit) on Bitget.
  • cancelBitgetOrder: Cancels an existing order by order ID or client order ID.
  • getBitgetOpenOrders: Retrieves all open orders for a specific symbol.
  • getBitgetOrderStatus: Fetches the status of a specific order by order ID or client order ID.

6. Futures Trading

  • getBitgetPosition: Retrieves position details for a given futures product.

Error Handling

Each function includes robust error handling and provides detailed error messages for common issues, such as:

  • Invalid API credentials.
  • Network connectivity issues.
  • API rate limits being exceeded.
  • Invalid parameters or unsupported symbols.

Environment Variables

The library requires the following environment variables to be set in a .env file:

  • BITGET_API_KEY: Your Bitget API key.
  • BITGET_API_SECRET: Your Bitget API secret.
  • BITGET_API_PASS: Your Bitget API passphrase.
  • RECV_WINDOW (optional): The receive window for API requests (default: 20000 ms).

Installation

  1. Clone the repository:
    git clone <repository-url>
  2. Install dependencies:
    npm install
  3. Create a .env file in the root directory and add your Bitget API credentials:
    BITGET_API_KEY=your_api_key
    BITGET_API_SECRET=your_api_secret
    BITGET_API_PASS=your_api_passphrase
    RECV_WINDOW=20000

License

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

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

Support

For any issues or questions, please contact the repository maintainer or open an issue in the GitHub repository.

Documentation

Detailed documentation for each module and component will be available soon. In the meantime, please refer to the TypeScript definitions (.d.ts files) for API details and function signatures.

Contributing

Contributions are welcome! Please read the CONTRIBUTING.md file for guidelines on how to contribute to this project.

License

MIT