Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ae_sdk

moh3a232MIT0.6.0TypeScript support: included

A simple SDK for Aliexpress (dropshipping and affiliate) APIs.

typescript, ae, aliexpress, sdk

readme

AliExpress SDK npm version

Typescript CI Publish Downloads Bundle Size License

A simple, lightweight, and fully type-safe SDK for the AliExpress Open Platform APIs. Supports System Authentication, Dropshipping, and Affiliate APIs.

📖 Overview

AliExpress has completely migrated their services from the legacy Taobao Open Platform to the new Open Platform for International Developers. While this update brought significant improvements, they have yet to release an official Node.js SDK for the new platform.

This unofficial SDK bridges that gap by providing a simple, consistent interface for Node.js developers to interact with AliExpress APIs.

✨ Features

This SDK provides several key capabilities:

🔐 Authentication & Security

  • Request Signing - Automatic generation of method signatures required by AliExpress
  • Session Management - Streamlined token generation and refresh flows
  • Error Handling - Consistent error responses with detailed messages

💻 Developer Experience

  • Type Safety - Fully typed parameters and responses for all API methods
  • Intuitive API - Clean, method-based approach to API calls

🛍️ Supported APIs

  • System Authentication - Token generation, refresh, and security token operations
  • Dropshipping API - Product details, order management, shipping calculations, and more
  • Affiliate API - Product discovery, link generation, commission tracking, and reporting

📦 Installation

# Using npm
npm install ae_sdk

# Using pnpm
pnpm add ae_sdk

# Using yarn
yarn add ae_sdk

🚀 Getting Started

Prerequisites

Before using this SDK, you'll need to complete several steps on the AliExpress Open Platform:

  1. Register as a Developer

  2. Create an Application

  3. Get API Credentials

  4. Obtain Access Token

Basic Usage

1. Initialize a Client

Choose the appropriate client based on your needs (System, Dropshipper, or Affiliate):

import { DropshipperClient } from "ae_sdk";

const client = new DropshipperClient({
  app_key: "YOUR_APP_KEY",
  app_secret: "YOUR_APP_SECRET",
  session: "ACCESS_TOKEN_FROM_AUTH_FLOW",
});

2. Make API Calls

Each client provides typed methods for different API operations:

// Get product details
const productResponse = await client.productDetails({
  product_id: 1005004043442825,
  ship_to_country: "US",
  target_currency: "USD",
  target_language: "en",
});

if (productResponse.ok) {
  console.log("Product:", productResponse.data);
}

3. Handle Responses

All API methods return a consistent response structure:

// Successful response
{
  ok: true,
  data: {
    // API-specific response data
    aliexpress_ds_product_get_response: {
      result: { /* product data */ },
      rsp_code: 200,
      rsp_msg: "Call succeeds",
      request_id: "1234567890"
    }
  }
}

// Error response
{
  ok: false,
  message: "Error message explaining what went wrong",
  request_id: "1234567890", // If available
  error_response: {}, // Full AliExpress error response if available
  error: {} // JavaScript Error object if applicable
}

📚 API Examples

System Client

For authentication and token management:

import { AESystemClient } from "ae_sdk";

const systemClient = new AESystemClient({
  app_key: "YOUR_APP_KEY",
  app_secret: "YOUR_APP_SECRET",
  session: "EXISTING_ACCESS_TOKEN", // Optional for some operations
});

// Generate a new token from an authorization code
const tokenResponse = await systemClient.generateToken({
  code: "AUTH_CODE_FROM_REDIRECT",
  uuid: "OPTIONAL_UUID",
});

// Refresh an existing token before it expires
const refreshResponse = await systemClient.refreshToken({
  refresh_token: "REFRESH_TOKEN_FROM_PREVIOUS_AUTH",
});

Affiliate Client

For affiliate marketing operations:

import { AffiliateClient } from "ae_sdk";

const affiliateClient = new AffiliateClient({
  app_key: "YOUR_APP_KEY",
  app_secret: "YOUR_APP_SECRET",
  session: "ACCESS_TOKEN",
});

// Generate affiliate tracking links
const linksResponse = await affiliateClient.generateAffiliateLinks({
  promotion_link_type: 0, // 0 for normal, 2 for hot product link
  source_values: "https://www.aliexpress.com/item/1234567890.html",
  tracking_id: "YOUR_TRACKING_ID",
  app_signature: "YOUR_APP_SIGNATURE",
});

// Find trending products with high commission rates
const hotProductsResponse = await affiliateClient.getHotProducts({
  app_signature: "YOUR_APP_SIGNATURE",
  keywords: "smartphone",
  page_no: 1,
  page_size: 20,
  platform_product_type: "ALL",
  ship_to_country: "US",
  sort: "SALE_PRICE_ASC",
  target_currency: "USD",
  target_language: "EN",
  tracking_id: "YOUR_TRACKING_ID",
});

Dropshipper Client

For dropshipping operations:

import { DropshipperClient } from "ae_sdk";

const dropshipperClient = new DropshipperClient({
  app_key: "YOUR_APP_KEY",
  app_secret: "YOUR_APP_SECRET",
  session: "ACCESS_TOKEN",
});

// Calculate shipping options and costs
const shippingResponse = await dropshipperClient.shippingInfo({
  country_code: "US",
  product_id: 1005004043442825,
  product_num: 2,
  province_code: "CA",
  city_code: "Los Angeles",
  send_goods_country_code: "CN",
  price: "29.99",
});

// Create a dropshipping order
const orderResponse = await dropshipperClient.createOrder({
  logistics_address: {
    address: "123 Main Street",
    city: "Los Angeles",
    country: "US",
    full_name: "John Doe",
    mobile_no: "123-456-7890",
    phone_country: "+1",
    province: "California",
    zip: "90001",
  },
  product_items: [
    {
      logistics_service_name: "AliExpress Standard Shipping",
      order_memo: "Customer order #12345",
      product_count: 2,
      product_id: 1005004043442825,
      sku_attr: "14:350853#Black;5:361386", // SKU specification attributes
    },
  ],
});

🔍 Advanced Usage

Direct API Calls

For APIs not yet included in the SDK:

const response = await client.callAPIDirectly(
  "aliexpress.custom.api.endpoint",
  {
    param1: "value1",
    param2: "value2",
    // Additional parameters as required by the API
  },
);

🤝 Contributing

Contributions are welcome! Feel free to open issues or submit pull requests for:

  • Bug fixes
  • New API endpoint support
  • Documentation improvements
  • Performance optimizations

📄 License

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

changelog

ae_sdk

<<<<<<< HEAD

0.6.0

Minor Changes

  • Added support for promotional payments in order creation while deprecating several legacy API methods.

    [Version 0.6.0]

    Added

    • Added promo_and_payment parameter to createOrder method

    Deprecated

    • Marked freightInfo, trackingInfo, and other legacy methods as deprecated

    Fixed

    • Improved README

      0.5.3

Patch Changes

  • Made callAPIDirectly method generic

    2d2cd0c080d410223b8055664b5abf1e5708a07b

0.5.2

Patch Changes

  • General bug fixes

0.5.1

Patch Changes

  • Rename $try to tryFn

0.5.0

Minor Changes

  • Add the entire AE error response to the returned object if available

0.4.17

Patch Changes

  • Normalize AE API's (aliexpress.logistics.buyer.freight.get endpoint) response for a product's freight info.

    await client.freightInfo({
      country_code: "DZ",
      send_goods_country_code: "CN",
      product_id: 123456,
      product_num: 1,
    });

0.4.16

Patch Changes

  • ae_sdk - Patch 0.4.16

    The Aliexpress Open Platform released a new method for dropshippers to calculate freight. Now added in the dropshipper client as freightInfo.

    const result = await client.freightInfo({
      country_code: "DZ",
      product_id: 123,
      product_num: 1,
      sku_id: "SKU#2:3",
    });

0.4.15

Patch Changes

  • Fix affiliate API endpoint (get feature promo) error

0.4.14

Patch Changes

  • Documentation

    • Write a simple documentation for basic usage

    Other

    • Refactor some code for aesthtics
    • Add initial unit tests

0.4.13

Patch Changes

  • Add shipping details parameter (tracking_available)

0.4.12

Patch Changes

    • Ensure API returns predefined types for AE affiliate API.

0.4.11

Patch Changes

  • Fix API sign method bug to support the new AE API signing format
  • Ensure API returns predefined types for AE dropshipping API

0.4.10

Patch Changes

  • Ensure API returns predefined types #5

0.4.9

Patch Changes

  • Ensure API returns predefined types #4

0.4.8

Patch Changes

  • Ensure API returns predefined types #3

0.4.7

Patch Changes

  • Ensure API returns predefined types #2

0.4.6

Patch Changes

  • Ensure API returns predefined types

0.4.5

Patch Changes

  • Fix accessing product details response #2

0.4.4

Patch Changes

  • Fix accessing product details response

0.4.3

Patch Changes

  • Add newly registered APIs support

0.4.2

Patch Changes

  • Export some relevant types #2

0.4.1

Patch Changes

  • Export some relevant types

0.4.0

Minor Changes

  • Fix affiliate API return types

0.3.4

Patch Changes

  • Fix dropshipping methods result types

0.3.3

Patch Changes

  • Add dropshipping API methods

0.3.2

Patch Changes

  • Finish affiliate API methods

0.3.1

Patch Changes

  • Add affiliate API methods

0.3.0

Minor Changes

  • Add system tool API and fix method signature

0.2.0

Minor Changes

  • Migrate to new AE API and add affiliate methods

0.1.0

Minor Changes

  • Added AE clients

0.0.5

Patch Changes

  • Added initial README

0.0.4

Patch Changes

  • Add license and npm dist folder

0.0.3

Patch Changes

  • 6afa68d: Added publish github action workflow and added changeset