ae_sdk
Version:
A simple SDK for Aliexpress (dropshipping and affiliate) APIs.
1,003 lines (994 loc) • 38.3 kB
JavaScript
"use strict";
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// src/index.ts
var src_exports = {};
__export(src_exports, {
AffiliateClient: () => AffiliateClient,
DropshipperClient: () => DropshipperClient
});
module.exports = __toCommonJS(src_exports);
// src/utils/index.ts
function parseAffiliateProducts(input) {
var _a;
if (!(input == null ? void 0 : input.products))
return input;
input.products = extractNestedArray(input.products, "product");
if (((_a = input.products) == null ? void 0 : _a.length) > 0) {
const firstProduct = input.products[0];
const hasStringImageUrls = (firstProduct == null ? void 0 : firstProduct.product_small_image_urls) && extractNestedProperty(firstProduct.product_small_image_urls, "string") !== null;
if (hasStringImageUrls) {
input.products = input.products.map((product) => __spreadProps(__spreadValues({}, product), {
product_small_image_urls: extractNestedArray(
product.product_small_image_urls,
"string"
)
}));
}
}
return input;
}
function extractNestedProperty(obj, nestedKey) {
if (!obj)
return null;
return nestedKey in obj ? obj[nestedKey] : null;
}
function extractNestedArray(obj, nestedKey) {
if (!obj)
return [];
if (nestedKey in obj && obj[nestedKey]) {
if (Array.isArray(obj[nestedKey])) {
return obj[nestedKey];
}
return [obj[nestedKey]].filter(Boolean);
}
return [];
}
function tryFn(promise) {
return __async(this, null, function* () {
try {
const data = yield promise;
return [void 0, data];
} catch (error) {
return [assertIsError(error), void 0];
}
});
}
function assertIsError(value) {
if (value instanceof Error)
return value;
let stringified = "[Unable to stringify the thrown value]";
try {
stringified = JSON.stringify(value);
} catch (e) {
}
const error = new Error(
`This value was thrown as is, not through an Error: ${stringified}`
);
return error;
}
// src/utils/client.ts
var import_crypto = require("crypto");
// src/constants.ts
var AE_TOP_API_URL = "https://api-sg.aliexpress.com/sync";
var AE_OP_API_URL = "https://api-sg.aliexpress.com/rest";
var SIGN_METHOD = "sha256";
var SIGN_METHOD_ENCODING = "utf-8";
var RESPONSE_FORMAT = "json";
// src/utils/client.ts
var AEBaseClient = class {
constructor(init) {
this.format = RESPONSE_FORMAT;
this.migrated_apis_url = AE_TOP_API_URL;
this.new_apis_url = AE_OP_API_URL;
this.sign_method = SIGN_METHOD;
this.app_key = init.app_key;
this.app_secret = init.app_secret;
this.session = init.session;
}
/**
* Generates a signature for the API request based on AliExpress API requirements.
*
* Creates an HMAC signature using the app secret and a sorted concatenation of
* all request parameters. The signature is used to authenticate the request
* and verify the integrity of the parameters.
*
* Handles both TOP API and OP API signature formats, which differ slightly
* in how the method parameter is handled.
*
* @param params - Request parameters to be signed
* @returns The generated HMAC signature as an uppercase hexadecimal string
*/
sign(params) {
const p = __spreadValues({}, params);
let basestring = "";
if (typeof p.method === "string" && p.method.includes("/")) {
basestring = p.method;
delete p.method;
}
basestring += Object.entries(p).filter(([_, value]) => value != null).sort(([a], [b]) => a.localeCompare(b)).reduce((acc, [key, value]) => acc + key + String(value), "");
return (0, import_crypto.createHmac)(SIGN_METHOD, this.app_secret, {
encoding: SIGN_METHOD_ENCODING
}).update(basestring).digest("hex").toUpperCase();
}
/**
* Constructs the complete URL for an API request with all parameters.
*
* Builds a properly formatted URL with query parameters for an AliExpress API request.
* Handles the differences between TOP API and OP API URL formats automatically
* based on the method name format.
*
* Parameters are sorted alphabetically and encoded properly for URL inclusion.
*
* @param params - Request parameters including the API method name
* @returns A complete URL string ready for the API request
*/
assemble(params) {
const p = __spreadValues({}, params);
const baseUrl = p.method.includes("/") ? `${this.new_apis_url}${p.method}` : this.migrated_apis_url;
if (p.method.includes("/")) {
delete p.method;
}
const queryParams = Object.entries(p).filter(([_, value]) => value != null).sort(([a], [b]) => a.localeCompare(b)).map(([key, value], index) => {
const prefix = index === 0 ? "?" : "&";
return `${prefix}${key}=${encodeURIComponent(String(value))}`;
}).join("");
return baseUrl + queryParams;
}
/**
* Sends a request to the AliExpress API and processes the response.
*
* Makes an HTTP POST request to the AliExpress API using the assembled URL
* and handles various error conditions including network errors, HTTP errors,
* and JSON parsing errors. Provides a standardized response format for both
* successful and failed requests.
*
* @param params - Complete set of parameters for the API request
* @returns A Result object containing either the parsed response data or error information
*/
call(params) {
return __async(this, null, function* () {
const [fetchError, response] = yield tryFn(
fetch(this.assemble(params), { method: "POST" })
);
if (fetchError) {
if (fetchError instanceof TypeError) {
return {
ok: false,
message: `Network Error: ${fetchError.message}`,
error: fetchError
};
}
return {
ok: false,
message: `Fetch Error: ${fetchError.message}`,
error: fetchError
};
}
if (!(response == null ? void 0 : response.ok))
return {
ok: false,
message: `HTTP Error: ${response == null ? void 0 : response.status} ${response == null ? void 0 : response.statusText}`
};
const [jsonError, data] = yield tryFn(response == null ? void 0 : response.json());
if (jsonError) {
if (jsonError instanceof SyntaxError) {
return {
ok: false,
message: `Invalid JSON Response: ${jsonError.message}`,
error: jsonError
};
}
return {
ok: false,
message: `JSON Parsing Error: ${jsonError.message}`,
error: jsonError
};
}
if (data == null ? void 0 : data.error_response)
return {
ok: false,
message: "Bad request",
error_response: data.error_response,
request_id: data.error_response.request_id
};
return { ok: true, data };
});
}
/**
* Executes a typed API method with the appropriate parameters.
*
* This method prepares and sends a strongly-typed request to the AliExpress API.
* It automatically adds required authentication parameters, generates the signature,
* and formats the request properly for the specified API method.
*
* The strong typing ensures that the correct parameter types are used for each API method
* and that the response is correctly typed according to the expected result.
*
* @param method - The AliExpress API method name to execute
* @param params - Method-specific parameters for the API call
* @returns A Result object with the strongly-typed response data or error information
*/
execute(method, params) {
return __async(this, null, function* () {
const parameters = __spreadProps(__spreadValues({}, params), {
method,
session: this.session,
app_key: this.app_key,
simplify: true,
sign_method: this.sign_method,
timestamp: Date.now()
});
parameters.sign = this.sign(parameters);
return yield this.call(parameters);
});
}
/**
* Executes an API call directly with a custom method name and parameters.
*
* This method allows for calling API endpoints that may not be covered by the
* strongly-typed methods, or for experimental or newly released API methods.
* It provides the same authentication, signing, and error handling but with
* less type safety.
*
* This is useful for testing new APIs or handling edge cases without needing to
* update the type definitions.
*
* @param method - The AliExpress API method name as a string
* @param params - Custom parameters for the API call
* @returns A Result object with the response data or error information
*/
callAPIDirectly(method, params) {
return __async(this, null, function* () {
if (!(method == null ? void 0 : method.trim()))
return {
ok: false,
message: "Method parameter is required"
};
if (!params || typeof params !== "object") {
return {
ok: false,
message: "Params must be a valid object"
};
}
const parameters = __spreadProps(__spreadValues({}, params), {
method,
session: this.session,
app_key: this.app_key,
simplify: true,
sign_method: this.sign_method,
timestamp: Date.now()
});
parameters.sign = this.sign(parameters);
return yield this.call(parameters);
});
}
};
// src/utils/system_client.ts
var AESystemClient = class extends AEBaseClient {
constructor(init) {
super(init);
}
/**
* Generates a new security token for enhanced API security.
*
* Creates a security token that provides an additional layer of authentication
* for sensitive API operations. Security tokens typically have stricter validation
* and shorter expiration times compared to standard tokens.
*
* @param args - Parameters required for security token generation
* @returns API response with the generated security token and related information
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=3&path=/auth/token/security/create&methodType=GET/POST
*/
generateSecurityToken(args) {
return __async(this, null, function* () {
return yield this.execute("/auth/token/security/create", args);
});
}
/**
* Generates a standard authentication token for API access.
*
* Creates a regular access token that can be used for most API operations.
* This is typically the first step in establishing an authenticated session
* with the AliExpress API system.
*
* @param args - Parameters required for token generation, including auth code
* @returns API response with the generated token and related information like expiration time
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=3&path=/auth/token/create&methodType=GET/POST
*/
generateToken(args) {
return __async(this, null, function* () {
return yield this.execute("/auth/token/create", args);
});
}
/**
* Refreshes an existing security token before it expires.
*
* Updates a security token to extend its validity period without requiring
* the user to go through the full authentication flow again. This should be
* called before the current security token expires to maintain uninterrupted
* access to secured API endpoints.
*
* @param args - Parameters required for security token refresh, including the refresh token
* @returns API response with the refreshed security token and updated expiration information
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=3&path=/auth/token/security/refresh&methodType=GET/POST
*/
refreshSecurityToken(args) {
return __async(this, null, function* () {
return yield this.execute("/auth/token/security/refresh", args);
});
}
/**
* Refreshes a standard authentication token before it expires.
*
* Updates a regular access token to extend its validity period without requiring
* the user to go through the full authentication flow again. This should be called
* before the current token expires to maintain uninterrupted API access.
*
* Token refresh is an essential part of maintaining long-running applications
* that interact with the AliExpress API.
*
* @param args - Parameters required for token refresh, including the refresh token
* @returns API response with the refreshed token and updated expiration information
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=3&path=/auth/token/refresh&methodType=GET/POST
*/
refreshToken(args) {
return __async(this, null, function* () {
return yield this.execute("/auth/token/refresh", args);
});
}
};
// src/utils/affiliate_client.ts
var AffiliateClient = class extends AESystemClient {
constructor(init) {
super(init);
}
/**
* Generates affiliate tracking links for products
*
* Creates trackable affiliate links that can be used in marketing campaigns,
* websites, or social media to earn commissions on referred sales.
*
* @param args Parameters including product IDs, tracking ID, and promotion types
* @returns API response with generated affiliate links
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21407&path=aliexpress.affiliate.link.generate&methodType=GET/POST
*/
generateAffiliateLinks(args) {
return __async(this, null, function* () {
let response = yield this.execute(
"aliexpress.affiliate.link.generate",
args
);
if (response.ok) {
let data = response.data.aliexpress_affiliate_link_generate_response.resp_result.result.promotion_links;
if (data.promotion_link) {
data = data.promotion_link;
}
}
return response;
});
}
/**
* Retrieves AliExpress category information for affiliate products
*
* Gets hierarchical category data that can be used for product browsing,
* filtering, or creating category-specific affiliate campaigns.
*
* @param args Parameters for retrieving category information
* @returns API response with category data
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21407&path=aliexpress.affiliate.category.get&methodType=GET/POST
*/
getCategories(args) {
return __async(this, null, function* () {
let response = yield this.execute(
"aliexpress.affiliate.category.get",
args
);
if (response.ok) {
let data = response.data.aliexpress_affiliate_category_get_response.resp_result.result.categories;
if (data.category) {
data = data.category;
}
}
return response;
});
}
/**
* Retrieves information about current featured promotions
*
* Gets details about ongoing promotional campaigns, sales events, and
* special offers that affiliates can promote to earn higher commissions.
*
* @param args Parameters for filtering and pagination of promotion information
* @returns API response with promotion details
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21407&path=aliexpress.affiliate.featuredpromo.get&methodType=GET/POST
*/
featuredPromoInfo(args) {
return __async(this, null, function* () {
let response = yield this.execute(
"aliexpress.affiliate.featuredpromo.get",
args
);
if (response.ok) {
let data = response.data.aliexpress_affiliate_featuredpromo_get_response.resp_result.result;
if (data.promos.promo) {
data.promos = data.promos.promo;
}
}
return response;
});
}
/**
* Retrieves products from a specific featured promotion
*
* Gets a list of products included in a particular promotional campaign or sale event,
* which can be used to create targeted affiliate marketing campaigns.
*
* @param args Parameters for specifying the promotion and filtering products
* @returns API response with products in the specified promotion
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21407&path=aliexpress.affiliate.featuredpromo.products.get&methodType=GET/POST
*/
featuredPromoProducts(args) {
return __async(this, null, function* () {
let response = yield this.execute(
"aliexpress.affiliate.featuredpromo.products.get",
args
);
if (response.ok) {
let data = response.data.aliexpress_affiliate_featuredpromo_products_get_response.resp_result.result;
data = parseAffiliateProducts(data);
}
return response;
});
}
/**
* Gets information about trending products for affiliate marketing
*
* @param args Parameters for filtering hot products by category, commission rate, etc.
* @returns API response with hot product download information
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21407&path=aliexpress.affiliate.hotproduct.download&methodType=GET/POST
*/
getHotProductsDownload(args) {
return __async(this, null, function* () {
let response = yield this.execute(
"aliexpress.affiliate.hotproduct.download",
args
);
if (response.ok) {
let data = response.data.aliexpress_affiliate_hotproduct_download_response.resp_result.result;
data = parseAffiliateProducts(data);
}
return response;
});
}
/**
* Retrieves a list of trending products for affiliate marketing
*
* Gets products that are currently popular on AliExpress with high sales volume
* and conversion rates, making them good candidates for affiliate promotion.
*
* @param args Parameters for filtering and pagination of hot products
* @returns API response with list of hot products
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21407&path=aliexpress.affiliate.hotproduct.query&methodType=GET/POST
*/
getHotProducts(args) {
return __async(this, null, function* () {
let response = yield this.execute(
"aliexpress.affiliate.hotproduct.query",
args
);
if (response.ok) {
let data = response.data.aliexpress_affiliate_hotproduct_query_response.resp_result.result;
data = parseAffiliateProducts(data);
}
return response;
});
}
/**
* Retrieves detailed information about a specific affiliate order
*
* Gets comprehensive details about an order placed through an affiliate link,
* including commission information, order status, and product details.
*
* @param args Parameters for order retrieval, including order ID
* @returns API response with complete order details
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21407&path=aliexpress.affiliate.order.get&methodType=GET/POST
*/
orderInfo(args) {
return __async(this, null, function* () {
return yield this.execute("aliexpress.affiliate.order.get", args);
});
}
/**
* Retrieves a list of affiliate orders based on specified criteria
*
* Gets information about multiple orders placed through affiliate links,
* filtered by date range, status, or other parameters.
*
* @param args Parameters for filtering and pagination of orders
* @returns API response with list of orders
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21407&path=aliexpress.affiliate.order.list&methodType=GET/POST
*/
ordersList(args) {
return __async(this, null, function* () {
return yield this.execute("aliexpress.affiliate.order.list", args);
});
}
/**
* Retrieves a paginated list of affiliate orders by index
*
* Gets a paginated list of orders for easier navigation through large sets of order data,
* using index-based pagination instead of time-based filtering.
*
* @param args Parameters for index-based pagination of orders
* @returns API response with paginated list of orders
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21407&path=aliexpress.affiliate.order.listbyindex&methodType=GET/POST
*/
ordersListByIndex(args) {
return __async(this, null, function* () {
return yield this.execute("aliexpress.affiliate.order.listbyindex", args);
});
}
/**
* Retrieves detailed information about a specific product for affiliate marketing
*
* Gets comprehensive product details including pricing, commission rates,
* images, descriptions, and other information needed for effective affiliate promotion.
*
* @param args Parameters for product retrieval, including product ID
* @returns API response with complete product details formatted for affiliate use
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21407&path=aliexpress.affiliate.productdetail.get&methodType=GET/POST
*/
productDetails(args) {
return __async(this, null, function* () {
let response = yield this.execute(
"aliexpress.affiliate.productdetail.get",
args
);
if (response.ok) {
let data = response.data.aliexpress_affiliate_productdetail_get_response.resp_result.result;
data = parseAffiliateProducts(data);
}
return response;
});
}
/**
* Searches for products available for affiliate promotion
*
* Searches the AliExpress catalog for products that can be promoted through
* the affiliate program, with filtering by category, price, commission rate, etc.
*
* @param args Parameters for product search and filtering
* @returns API response with product search results
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21407&path=aliexpress.affiliate.product.query&methodType=GET/POST
*/
queryProducts(args) {
return __async(this, null, function* () {
let response = yield this.execute(
"aliexpress.affiliate.product.query",
args
);
if (response.ok) {
let data = response.data.aliexpress_affiliate_product_query_response.resp_result.result;
data = parseAffiliateProducts(data);
}
return response;
});
}
/**
* Finds similar products that match given criteria
*
* Uses intelligent matching to find products similar to provided keywords, URLs,
* or product IDs, which can be used to diversify affiliate product offerings.
*
* @param args Parameters for smart matching, including keywords or reference products
* @returns API response with matched products
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21407&path=aliexpress.affiliate.product.smartmatch&methodType=GET/POST
*/
smartMatchProducts(args) {
return __async(this, null, function* () {
let response = yield this.execute(
"aliexpress.affiliate.product.smartmatch",
args
);
if (response.ok) {
let data = response.data.aliexpress_affiliate_product_smartmatch_response.resp_result.result;
data = parseAffiliateProducts(data);
}
return response;
});
}
};
// src/utils/ds_client.ts
var DropshipperClient = class extends AESystemClient {
constructor(init) {
super(init);
}
/**
* @deprecated - this was removed from the API
*
* Retrieves freight information for products
*
* AE API endpoint: `aliexpress.logistics.buyer.freight.get`
*
* @param args Freight calculation parameters including product and shipping details
* @returns API response with freight calculation results
* @link https://openservice.aliexpress.com/doc/api.htm#/api?cid=21038&path=aliexpress.logistics.buyer.freight.get&methodType=GET/POST
*/
freightInfo(args) {
return __async(this, null, function* () {
let response = yield this.execute(
"aliexpress.logistics.buyer.freight.get",
{
aeopFreightCalculateForBuyerDTO: JSON.stringify(args)
}
);
if (response.ok) {
const data = response.data.aliexpress_logistics_buyer_freight_get_response;
if (data.result.success && data.result.aeop_freight_calculate_result_for_buyer_dtolist) {
data.result.aeop_freight_calculate_result_for_buyer_dtolist = extractNestedArray(
data.result.aeop_freight_calculate_result_for_buyer_dtolist,
"aeop_freight_calculate_result_for_buyer_d_t_o"
);
}
}
return response;
});
}
/**
* Calculates shipping costs for buyer-selected options
*
* Uses the AliExpress shipping calculation API to get available shipping methods
* and their associated costs based on product, quantity, and destination.
*
* @param args Shipping information parameters including product and destination details
* @returns API response with available shipping methods and costs
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21038&path=aliexpress.logistics.buyer.freight.calculate&methodType=GET/POST
*/
shippingInfo(args) {
return __async(this, null, function* () {
let response = yield this.execute(
"aliexpress.logistics.buyer.freight.calculate",
{
param_aeop_freight_calculate_for_buyer_d_t_o: JSON.stringify(args)
}
);
if (response.ok) {
const data = response.data.aliexpress_logistics_buyer_freight_calculate_response;
if (data.result.success && data.result.aeop_freight_calculate_result_for_buyer_d_t_o_list) {
data.result.aeop_freight_calculate_result_for_buyer_d_t_o_list = extractNestedArray(
data.result.aeop_freight_calculate_result_for_buyer_d_t_o_list,
"aeop_freight_calculate_result_for_buyer_dto"
);
}
}
return response;
});
}
/**
* @deprecated - this was removed from the API
*
* Retrieves tracking information for an order
*
* Gets detailed tracking events for a shipment using the order ID
* and logistics tracking number.
*
* @param args Tracking information parameters including order ID and tracking number
* @returns API response with tracking details and events
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21038&path=aliexpress.logistics.ds.trackinginfo.query&methodType=GET/POST
*/
trackingInfo(args) {
return __async(this, null, function* () {
var _a;
let response = yield this.execute(
"aliexpress.logistics.ds.trackinginfo.query",
args
);
if (response.ok && response.data.aliexpress_logistics_ds_trackinginfo_query_response.result_success) {
const data = response.data.aliexpress_logistics_ds_trackinginfo_query_response;
data.details = (_a = extractNestedProperty(data.details, "details")) != null ? _a : [];
}
return response;
});
}
// TODO : add new tracking info API route
// https://openservice.aliexpress.com/doc/doc.htm#/?docId=1660
/**
* @deprecated - this was removed from the API
*
* Adds dropshipping information to an order
*
* @param args Dropshipping information parameters
* @returns API response with operation result
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21038&path=aliexpress.ds.add.info&methodType=GET/POST
*/
addDropshippingInfo(args) {
return __async(this, null, function* () {
return yield this.execute("aliexpress.ds.add.info", {
param0: JSON.stringify(args)
});
});
}
/**
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21038&path=aliexpress.ds.image.search&methodType=GET/POST
*/
// TODO
// async searchByImage(args: DS_Image_Search_Params) {
// let response = await this.execute("aliexpress.ds.image.search", args);
// if (response.ok) {
// let data = response.data.aliexpress_ds_image_search_response.data;
// data = parseAffiliateProducts(data);
// }
// return response;
// }
/**
* @deprecated - this was removed from the API
*
* Retrieves recommended products from featured promotions
*
* @param args Parameters for filtering and pagination of recommended products
* @returns API response with recommended products
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21038&path=aliexpress.ds.recommend.feed.get&methodType=GET/POST
*/
queryfeaturedPromoProducts(args) {
return __async(this, null, function* () {
let response = yield this.execute("aliexpress.ds.recommend.feed.get", args);
if (response.ok) {
response.data.aliexpress_ds_recommend_feed_get_response.resp_result.result = parseAffiliateProducts(
response.data.aliexpress_ds_recommend_feed_get_response.resp_result.result
);
}
return response;
});
}
/**
* Creates a new order on AliExpress
*
* Places an order with the specified shipping address and product items.
* This is the main endpoint for creating dropshipping orders.
*
* @param params Object containing logistics_address (shipping details) and product_items (products to order)
* @returns API response with order creation result, including order numbers
* @link https://openservice.aliexpress.com/doc/api.htm#/api?cid=21038&path=aliexpress.ds.order.create&methodType=GET/POST
*/
createOrder(_0) {
return __async(this, arguments, function* ({
logistics_address,
product_items,
promo_and_payment
}) {
var _a;
let response = yield this.execute("aliexpress.ds.order.create", {
ds_extend_request: JSON.stringify(promo_and_payment),
param_place_order_request4_open_api_d_t_o: JSON.stringify({
logistics_address,
product_items
})
});
if (response.ok && response.data.aliexpress_trade_buy_placeorder_response.result.is_success) {
response.data.aliexpress_trade_buy_placeorder_response.result.order_list = (_a = extractNestedProperty(
response.data.aliexpress_trade_buy_placeorder_response.result.order_list,
"number"
)) != null ? _a : [];
}
return response;
});
}
/**
* Retrieves detailed information about an order
*
* Gets comprehensive order details including products, shipping information,
* payment status, and other order-related data.
*
* @param args Parameters for order retrieval, including order ID
* @returns API response with complete order details
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21038&path=aliexpress.trade.ds.order.get&methodType=GET/POST
*/
orderDetails(args) {
return __async(this, null, function* () {
let response = yield this.execute("aliexpress.trade.ds.order.get", args);
if (response.ok) {
response.data.aliexpress_trade_ds_order_get_response = extractNestedProperty(
response.data,
"aliexpress_ds_trade_order_get_response"
) || response.data.aliexpress_trade_ds_order_get_response;
if (response.data.aliexpress_ds_trade_order_get_response) {
delete response.data.aliexpress_ds_trade_order_get_response;
}
let data = response.data.aliexpress_trade_ds_order_get_response.result;
if ("child_order_list" in data && data.child_order_list) {
data.child_order_list = extractNestedArray(
data.child_order_list,
"ae_child_order_info"
);
}
if (data.logistics_info_list) {
data.logistics_info_list = extractNestedArray(
data.logistics_info_list,
"ae_order_logistics_info"
);
}
}
return response;
});
}
/**
* Retrieves available featured promotions
*
* Gets a list of current promotional campaigns available for dropshippers,
* which can be used to find discounted products.
*
* @param args Parameters for filtering and pagination of promotions
* @returns API response with available promotions
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21038&path=aliexpress.ds.feedname.get&methodType=GET/POST
*/
queryFeaturedPromos(args) {
return __async(this, null, function* () {
let response = yield this.execute("aliexpress.ds.feedname.get", args);
if (response.ok) {
let data = response.data.aliexpress_ds_feedname_get_response.result.promos;
data = extractNestedArray(data, "promo");
}
return response;
});
}
/**
* Retrieves AliExpress category information
*
* Gets hierarchical category data that can be used for product browsing
* or filtering in dropshipping applications.
*
* @param args Parameters for retrieving category information
* @returns API response with category data
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21038&path=aliexpress.ds.category.get&methodType=GET/POST
*/
getCategories(args) {
return __async(this, null, function* () {
let response = yield this.execute("aliexpress.ds.category.get", args);
if (response.ok) {
let data = response.data.aliexpress_ds_category_get_response.resp_result.result.categories;
data = extractNestedArray(data, "category");
}
return response;
});
}
/**
* @deprecated - this was removed from the API
*
* Retrieves a list of orders by index
*
* Gets paginated orders based on specified filters and sorting parameters.
* Useful for building order management interfaces.
*
* @param args Parameters for filtering and pagination of orders
* @returns API response with list of orders
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21038&path=aliexpress.ds.commissionorder.listbyindex&methodType=GET/POST
*/
ordersListByIndex(args) {
return __async(this, null, function* () {
return yield this.execute(
"aliexpress.ds.commissionorder.listbyindex",
args
);
});
}
/**
* @deprecated - this was removed from the API
*
* Submits order data to AliExpress
*
* Submits additional information about orders, such as tracking data
* or customer information for dropshipping purposes.
*
* @param args Order data to submit
* @returns API response with submission result
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21038&path=aliexpress.ds.member.orderdata.submit&methodType=GET/POST
*/
submitOrderData(args) {
return __async(this, null, function* () {
return yield this.execute("aliexpress.ds.member.orderdata.submit", args);
});
}
/**
* Retrieves detailed product information
*
* Gets comprehensive information about a product, including pricing,
* variations, shipping options, seller information, and other product details.
* This is a core API for dropshipping product sourcing.
*
* @param args Parameters for product retrieval, including product ID
* @returns API response with complete product details
* @link https://open.aliexpress.com/doc/api.htm#/api?cid=21038&path=aliexpress.ds.product.get&methodType=GET/POST
*/
productDetails(args) {
return __async(this, null, function* () {
var _a;
let response = yield this.execute("aliexpress.ds.product.get", args);
if (response.ok) {
const data = response.data.aliexpress_ds_product_get_response.result;
data.ae_item_properties = extractNestedArray(
data.ae_item_properties,
"ae_item_property"
);
data.ae_item_sku_info_dtos = extractNestedArray(
data.ae_item_sku_info_dtos,
"ae_item_sku_info_d_t_o"
);
data.ae_item_sku_info_dtos.forEach((sku) => {
if (sku.ae_sku_property_dtos) {
sku.aeop_s_k_u_propertys = sku.ae_sku_property_dtos;
delete sku.ae_sku_property_dtos;
}
sku.aeop_s_k_u_propertys = extractNestedArray(
sku.aeop_s_k_u_propertys,
"ae_sku_property_d_t_o"
);
});
if ((_a = data.ae_multimedia_info_dto) == null ? void 0 : _a.ae_video_dtos) {
data.ae_multimedia_info_dto.ae_video_dtos = extractNestedArray(
data.ae_multimedia_info_dto.ae_video_dtos,
"ae_video_d_t_o"
);
}
}
return response;
});
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
AffiliateClient,
DropshipperClient
});