ae_sdk
Version:
A simple SDK for Aliexpress (dropshipping and affiliate) APIs.
1,409 lines (1,403 loc) • 73.1 kB
TypeScript
type AE_API_NAMES = DS_API_NAMES | AFFILIATE_API_NAMES | SYSTEM_API_NAMES;
type DS_API_NAMES = "aliexpress.logistics.buyer.freight.get" | "aliexpress.logistics.buyer.freight.calculate" | "aliexpress.logistics.ds.trackinginfo.query" | "aliexpress.ds.add.info" | "aliexpress.ds.image.search" | "aliexpress.ds.recommend.feed.get" | "aliexpress.ds.order.create" | "aliexpress.trade.ds.order.get" | "aliexpress.ds.feedname.get" | "aliexpress.ds.category.get" | "aliexpress.ds.commissionorder.listbyindex" | "aliexpress.ds.member.orderdata.submit" | "aliexpress.ds.product.get";
type AFFILIATE_API_NAMES = "aliexpress.affiliate.link.generate" | "aliexpress.affiliate.category.get" | "aliexpress.affiliate.featuredpromo.get" | "aliexpress.affiliate.featuredpromo.products.get" | "aliexpress.affiliate.hotproduct.download" | "aliexpress.affiliate.hotproduct.query" | "aliexpress.affiliate.order.get" | "aliexpress.affiliate.order.list" | "aliexpress.affiliate.order.listbyindex" | "aliexpress.affiliate.productdetail.get" | "aliexpress.affiliate.product.query" | "aliexpress.affiliate.product.smartmatch";
type SYSTEM_API_NAMES = "/auth/token/security/create" | "/auth/token/create" | "/auth/token/security/refresh" | "/auth/token/refresh";
/**
* Public parameters
* @description Public parameters need to be set for every Aliexpress API
* @param {String} method Indicates the API name.
* @param {String | undefined} app_key Indicates the AppKey allocated by the TOP to an application. An ISV can choose Open Platform Console > Application Management > Overview to check the AppKey and AppSecret of the formal environment.
* @param {String} session Indicates the authorization granted by the TOP to an application after a user logs in and grants authorization successfully.
* @param {String} timestamp Indicates the time stamp in the format of yyyy-MM-dd HH:mm:ss and in the time zone of GMT+8. For example, 2016-01-01 12:00:00. The Taobao API server allows a maximum time error of 10 minutes for a request from a client.
* @param {Boolean} simplify Indicates whether the simplified JSON return format is used. This parameter is valid only if format is set to json. The default value is false.
* @param {String} sign_method Indicates the signature digest algorithm. The value can be set to hmac or md5.
* @param {String} sign Indicates the obtained signature of API input parameters.
*/
interface PublicParams {
app_key: string;
session: string;
timestamp: number;
sign_method: "hmac" | "md5" | "sha256";
method: AE_API_NAMES;
sign?: string;
simplify?: boolean;
}
interface AE_Base_Client {
/**
* @param {String} app_key Indicates the AppKey allocated by Open.Aliexpress to an application. An ISV can choose Open Platform Console > Application Management > Overview to check the AppKey and AppSecret of the formal environment.
* @link https://open.aliexpress.com/doc/doc.htm?nodeId=27493&docId=118729#/?docId=732
*/
app_key: string;
/**
* @param {String} app_key Indicates the AppSecret allocated by Open.Aliexpress to an application. An ISV can choose Open Platform Console > Application Management > Overview to check the AppKey and AppSecret of the formal environment.
* @link https://open.aliexpress.com/doc/doc.htm?nodeId=27493&docId=118729#/?docId=732
*/
app_secret: string;
/**
* @param {String} session Indicates the authorization granted by the TOP to an application after a user logs in and grants authorization successfully.
* @link https://open.aliexpress.com/doc/doc.htm?nodeId=27493&docId=118729#/?docId=730
*/
session: string;
}
type AliexpressMethod<T extends AE_API_NAMES> = T extends "/auth/token/security/create" ? {
method: T;
params: AES_Generate_Security_Token_Params;
result: AES_Generate_Security_Token_Result;
} : T extends "/auth/token/create" ? {
method: T;
params: AES_Generate_Token_Params;
result: AES_Generate_Token_Result;
} : T extends "/auth/token/security/refresh" ? {
method: T;
params: AES_Refresh_Security_Token_Params;
result: AES_Refresh_Security_Token_Result;
} : T extends "/auth/token/refresh" ? {
method: "/auth/token/refresh";
params: AES_Refresh_Token_Params;
result: AES_Refresh_Token_Result;
} : T extends "aliexpress.logistics.buyer.freight.get" ? {
method: T;
params: DS_Freight_Calculation_Params;
result: DS_Freight_Calculation_Result;
} : T extends "aliexpress.logistics.buyer.freight.calculate" ? {
method: T;
params: DS_Shipping_Info_Params;
result: DS_Shipping_Info_Result;
} : T extends "aliexpress.logistics.ds.trackinginfo.query" ? {
method: T;
params: DS_Tracking_Info_Params;
result: DS_Tracking_Info_Result;
} : T extends "aliexpress.ds.add.info" ? {
method: T;
params: DS_Add_Info_Params;
result: DS_Add_Info_Result;
} : T extends "aliexpress.ds.image.search" ? {
method: T;
params: DS_Image_Search_Params;
result: DS_Image_Search_Result;
} : T extends "aliexpress.ds.recommend.feed.get" ? {
method: T;
params: DS_Recommended_Products_Params;
result: DS_Recommended_Products_Result;
} : T extends "aliexpress.ds.order.create" ? {
method: T;
params: DS_Place_Order_Params;
result: DS_Place_Order_Result;
} : T extends "aliexpress.trade.ds.order.get" ? {
method: T;
params: DS_Get_Order_Params;
result: DS_Get_Order_Result;
} : T extends "aliexpress.ds.feedname.get" ? {
method: T;
params: DS_Feedname_Params;
result: DS_Feedname_Result;
} : T extends "aliexpress.ds.category.get" ? {
method: T;
params: Affiliate_Categories_Params;
result: DS_Categories_Result;
} : T extends "aliexpress.ds.commissionorder.listbyindex" ? {
method: T;
params: DS_Orders_ByIdx_Params;
result: DS_Orders_ByIdx_Result;
} : T extends "aliexpress.ds.member.orderdata.submit" ? {
method: T;
params: DS_Order_Submit_Params;
result: DS_Order_Submit_Result;
} : T extends "aliexpress.ds.product.get" ? {
method: T;
params: DS_Product_Params;
result: DS_Product_Result;
} : T extends "aliexpress.affiliate.link.generate" ? {
method: T;
params: Affiliate_Generate_Affiliate_Links_Params;
result: Affiliate_Generate_Affiliate_Links_Result;
} : T extends "aliexpress.affiliate.category.get" ? {
method: T;
params: Affiliate_Categories_Params;
result: Affiliate_Categories_Result;
} : T extends "aliexpress.affiliate.featuredpromo.get" ? {
method: T;
params: Affiliate_Featuredpromo_Info_Params;
result: Affiliate_Featuredpromo_Info_Result;
} : T extends "aliexpress.affiliate.featuredpromo.products.get" ? {
method: T;
params: Affiliate_Featured_Promo_Products_Params;
result: Affiliate_Featured_Promo_Products_Result;
} : T extends "aliexpress.affiliate.hotproduct.download" ? {
method: T;
params: Affiliate_Hotproducts_Download_Params;
result: Affiliate_Hotproducts_Download_Result;
} : T extends "aliexpress.affiliate.hotproduct.query" ? {
method: T;
params: Affiliate_Hotproducts_Params;
result: Affiliate_Hotproducts_Result;
} : T extends "aliexpress.affiliate.order.get" ? {
method: T;
params: Affiliate_Order_Info_Params;
result: Affiliate_Order_Info_Result;
} : T extends "aliexpress.affiliate.order.list" ? {
method: T;
params: Affiliate_Order_List_Params;
result: Affiliate_Order_List_Result;
} : T extends "aliexpress.affiliate.order.listbyindex" ? {
method: T;
params: Affiliate_Order_List_ByIdx_Params;
result: Affiliate_Order_List_ByIdx_Result;
} : T extends "aliexpress.affiliate.productdetail.get" ? {
method: T;
params: Affiliate_Product_Details_Params;
result: Affiliate_Product_Details_Result;
} : T extends "aliexpress.affiliate.product.query" ? {
method: T;
params: Affiliate_Products_Params;
result: Affiliate_Products_Result;
} : T extends "aliexpress.affiliate.product.smartmatch" ? {
method: T;
params: Affiliate_Smart_Match_Products_Params;
result: Affiliate_Smart_Match_Products_Result;
} : {
method: T;
params: Record<string, string | number | boolean>;
result: unknown;
};
type AE_Platform_Type = "TMALL" | "ALL" | "PLAZA";
type AE_Language = "EN" | "RU" | "PT" | "ES" | "FR" | "ID" | "IT" | "TH" | "JA" | "AR" | "VI" | "TR" | "DE" | "HE" | "KO" | "NL" | "PL" | "MX" | "CL" | "IW" | "IN";
type AE_Currency = "USD" | "GBP" | "CAD" | "EUR" | "CNY" | "UAH" | "MXN" | "TRY" | "RUB" | "BRL" | "AUD" | "INR" | "JPY" | "IDR" | "SEK" | "KRW";
type AE_Locale_Site = "global" | "it_site" | "es_site" | "ru_site";
type AE_Sort_Filter = "SALE_PRICE_ASC" | "SALE_PRICE_DESC" | "LAST_VOLUME_ASC" | "LAST_VOLUME_DESC";
type AE_Sort_Promo_Filter = "commissionAsc" | "commissionDesc" | "priceAsc" | "priceDesc" | "volumeAsc" | "volumeDesc" | "discountAsc" | "discountDesc" | "ratingAsc" | "ratingDesc" | "promotionTimeAsc" | "promotionTimeDesc";
type AE_Order_Status = "PLACE_ORDER_SUCCESS" | "WAIT_BUYER_ACCEPT_GOODS" | "FUND_PROCESSING" | "FINISH";
type AE_Logistics_Status = "NO_LOGISTICS" | "WAIT_SELLER_SEND_GOODS" | "SELLER_SEND_GOODS" | "BUYER_ACCEPT_GOODS";
type YES_NO = "Y" | "N";
/**
* AFFILIATE API
* PRODUCT DETAILS
*/
interface Affiliate_Product_Promo_Code_Info {
promo_code?: string;
code_campaigntype?: string;
code_value?: string;
code_availabletime_start?: string;
code_availabletime_end?: string;
code_mini_spend?: string;
code_quantity?: string;
code_promotionurl?: string;
}
interface Affiliate_Base_Product_Params {
app_signature?: string;
/** Respond parameter list. eg: commission_rate,sale_price */
fields?: string;
target_currency?: AE_Currency;
target_language?: AE_Language;
tracking_id?: string;
}
interface Affiliate_Base_Product_Details {
app_sale_price?: string;
app_sale_price_currency?: AE_Currency;
commission_rate?: string;
discount?: string;
evaluate_rate?: string;
first_level_category_id?: number;
first_level_category_name?: string;
hot_product_commission_rate?: string;
lastest_volume?: number;
original_price?: string;
original_price_currency?: AE_Currency;
platform_product_type?: AE_Platform_Type;
product_detail_url?: string;
product_id?: number;
product_main_image_url?: string;
product_small_image_urls?: string[];
product_title?: string;
product_video_url?: string;
promotion_link?: string;
promo_code_info?: Affiliate_Product_Promo_Code_Info;
relevant_market_commission_rate?: string;
sale_price: string;
sale_price_currency: AE_Currency;
second_level_category_id: number;
second_level_category_name: string;
shop_id: number;
shop_url: string;
target_app_sale_price: string;
target_original_price: string;
target_sale_price: string;
target_original_price_currency: AE_Currency;
target_sale_price_currency: AE_Currency;
target_app_sale_price_currency: AE_Currency;
ship_to_days?: string;
}
interface Affiliate_Base_Products_Cursor {
products?: Affiliate_Base_Product_Details[];
current_record_count?: number;
current_page_no?: number;
total_page_no?: number;
total_record_count?: number;
is_finished?: boolean;
}
interface Affiliate_Base_Products_Cursor_Response {
resp_result: {
result: Affiliate_Base_Products_Cursor;
resp_code?: number;
resp_msg?: string;
};
}
/**
* AFFILIATE API
* PRODUCT DETAILS
*/
interface Affiliate_Product_Details_Params extends Affiliate_Base_Product_Params {
product_ids: string;
country?: string;
}
interface Affiliate_Product_Details_Result {
aliexpress_affiliate_productdetail_get_response: Affiliate_Base_Products_Cursor_Response;
}
/**
* AFFILIATE API
* QUERY PRODUCTS
*/
interface Affiliate_Products_Params extends Affiliate_Base_Product_Params {
/** List of category ID, you can get category ID via "get category" API https://developers.aliexpress.com/en/doc.htm?docId=45801&docType=2 */
category_ids?: string;
keywords?: string;
/** Filter products by highest price, unit cent */
max_sale_price?: string;
/** Filter products by lowest price, unit cent */
min_sale_price?: string;
page_no?: string;
/** record count of each page, 1 - 50 */
page_size?: string;
platform_product_type?: AE_Platform_Type;
sort?: AE_Sort_Filter;
/** Estimated delivery days. 3:in 3 days,5:in 5 days,7:in 7 days,10:in 10 days */
delivery_days?: string;
/** The Ship to country. Filter products that can be sent to that country; Returns the price according to the country’s tax rate policy. */
ship_to_country?: string;
}
interface Affiliate_Products_Result {
aliexpress_affiliate_product_query_response: Affiliate_Base_Products_Cursor_Response;
}
/**
* AFFILIATE API
* HOTPRODUCTS
*/
interface Affiliate_Hotproducts_Params extends Affiliate_Products_Params {
}
interface Affiliate_Hotproducts_Result {
aliexpress_affiliate_hotproduct_query_response: Affiliate_Base_Products_Cursor_Response;
}
/**
* AFFILIATE API
* FEATURED PROMO PRODUCTS
*/
interface Affiliate_Featured_Promo_Products_Params extends Affiliate_Base_Product_Params {
category_id?: string;
page_no?: string;
page_size?: string;
promotion_end_time?: string;
promotion_name?: string;
promotion_start_time?: string;
sort?: AE_Sort_Promo_Filter;
country?: string;
}
interface Affiliate_Featured_Promo_Products_Result {
aliexpress_affiliate_featuredpromo_products_get_response: Affiliate_Base_Products_Cursor_Response;
}
/**
* AFFILIATE API
* GET HOTPRODUCT DOWNLOAD
*/
interface Affiliate_Hotproducts_Download_Params {
/** API signature */
app_signature?: string;
/** Category ID, you can get category ID via "get category" API https://developers.aliexpress.com/en/doc.htm?docId=45801&docType=2 */
category_id: string;
/** Respond parameter list. eg: commission_rate,sale_price */
fields?: string;
/** Local site:global, it_site, es_site, ru_site */
locale_site?: AE_Locale_Site;
page_no?: number;
page_size?: number;
/** Target Currency:USD, GBP, CAD, EUR, UAH, MXN, TRY, RUB, BRL, AUD, INR, JPY, IDR, SEK,KRW,ILS,THB,CLP,VND */
target_currency?: AE_Currency;
/** Target Language:EN,RU,PT,ES,FR,ID,IT,TH,JA,AR,VI,TR,DE,HE,KO,NL,PL,MX,CL,IN */
target_language?: AE_Language;
/** Your trackingID */
tracking_id?: string;
/** The Ship to country. Filter products that can be sent to that country; Returns the price according to the country’s tax rate policy.*/
country?: string;
}
interface Affiliate_Hotproducts_Download_Result {
aliexpress_affiliate_hotproduct_download_response: Affiliate_Base_Products_Cursor_Response;
}
/**
* AFFILIATE API
* SMART MATCH PRODUCTS
*/
interface Affiliate_Smart_Match_Products_Params {
/** App information */
app?: string;
/** API signature */
app_signature?: string;
/** Device infomation */
device?: string;
/** adid or idfa, for more information please refer to https://support.google.com/admanager/answer/6238701 Can be null, if it is null, it can be recommended based on keywords or product ID */
device_id: string;
/** Respond parameter list, eg: commission_rate,sale_price */
fields?: string;
/** Recommend products by keywords. eg: mp3 */
keywords?: string;
/** Request page number */
page_no?: number;
/** Product ID, matching related products product ID */
product_id?: string;
/** site information */
site?: string;
/** Target Currency: USD, GBP, CAD, EUR, UAH, MXN, TRY, RUB, BRL, AUD, INR, JPY, IDR, SEK,KRW,ILS,THB,CLP,VND */
target_currency?: AE_Currency;
/** Target Languages: EN,RU,PT,ES,FR,ID,IT,TH,JA,AR,VI,TR,DE,HE,KO,NL,PL,MX,CL,IN */
target_language?: AE_Language;
tracking_id?: string;
/** user id */
user?: string;
/** The Ship to country. Filter products that can be sent to that country; Returns the price according to the country’s tax rate policy. */
country?: string;
}
interface Affiliate_Smart_Match_Products_Result {
aliexpress_affiliate_product_smartmatch_response: Affiliate_Base_Products_Cursor_Response;
}
/**
* AFFILIATE API
* GENERATE AFFILIATE LINKS
*/
interface Affiliate_Generate_Affiliate_Links_Params {
/** Promotion link type: 0 for normal link which has standard commission , and 2 for hot link which has hot product commission */
promotion_link_type: number;
source_values: string;
tracking_id: string;
app_signature?: string;
}
interface Affiliate_Promo_Link {
promotion_link: string;
source_value: string;
}
interface Affiliate_Generate_Affiliate_Links {
total_result_count: number;
tracking_id: string;
promotion_links: Affiliate_Promo_Link[];
}
interface Affiliate_Generate_Affiliate_Links_Result {
aliexpress_affiliate_link_generate_response: {
resp_result: {
resp_code?: number;
resp_msg?: string;
result: Affiliate_Generate_Affiliate_Links;
};
};
}
/**
* AFFILIATE API
* CATEGORIES
*/
interface Affiliate_Categories_Params {
app_signature?: string;
}
interface Affiliate_Category_Details {
category_id: number;
category_name: string;
parent_category_id: number;
}
interface Affiliate_Categories {
categories: Affiliate_Category_Details[];
total_result_count: number;
}
interface Affiliate_Categories_Result {
aliexpress_affiliate_category_get_response: {
resp_result: {
resp_code: number;
resp_msg: string;
result: Affiliate_Categories;
};
};
}
/**
* AFFILIATE API
* FEATURED PROMO INFO
*/
interface Affiliate_Featuredpromo_Info_Params extends Affiliate_Categories_Params {
}
interface Affiliate_Featuredpromo_Details {
promo_desc: string;
promo_name: string;
product_num: number;
}
interface Affiliate_Featuredpromo_Info {
current_record_count: number;
promos: Affiliate_Featuredpromo_Details[];
}
interface Affiliate_Featuredpromo_Info_Response {
resp_code?: number;
resp_msg?: string;
result: Affiliate_Featuredpromo_Info;
}
interface Affiliate_Featuredpromo_Info_Result {
aliexpress_affiliate_featuredpromo_get_response: {
resp_result: Affiliate_Featuredpromo_Info_Response;
};
}
/**
* AFFILIATE API
* GET ORDER INFO
*/
interface Affiliate_Order_Info_Params {
app_signature?: string;
fields?: string;
order_ids?: string;
}
interface Affiliate_Order_Details {
estimated_finished_commission: number;
product_detail_url: string;
estimated_paid_commission: number;
product_count: number;
order_number: number;
is_hot_product: YES_NO;
parent_order_number: number;
product_main_image_url: string;
order_status: string;
settled_currency: AE_Currency;
category_id: number;
product_id: number;
order_type: string;
tracking_id: string;
created_time: string;
finished_time: string;
completed_settlement_time: string;
paid_time: string;
customer_parameters: string;
is_new_buyer: YES_NO;
ship_to_country: string;
sub_order_id: number;
product_title: string;
incentive_commission_rate: string;
new_buyer_bonus_commission: number;
estimated_incentive_paid_commission: number;
is_affiliate_product: YES_NO;
paid_amount: number;
effect_detail_status: string;
estimated_incentive_finished_commission: number;
commission_rate: string;
finished_amount: number;
order_id: number;
}
interface Affiliate_Order_Info {
current_record_count: number;
orders: Affiliate_Order_Details[];
}
interface Affiliate_Order_Info_Result {
aliexpress_affiliate_order_get_response: {
resp_result: {
result: Affiliate_Order_Info;
resp_code?: number;
resp_msg?: string;
};
};
}
/**
* AFFILIATE API
* GET ORDER LIST
*/
interface Affiliate_Order_List_Params {
/** The type of time you are querying: Payment Completed Time(The time of payment for the order), Buyer Confirmed Receipt Time(The time when the buyer confirms receipt) Completed Settlement Time(The time when commission is paid into Account Balance) */
time_type?: string;
/** API signature */
app_signature?: string;
/** End time, PST time */
end_time: string;
/** Respond parameter list. eg: commission_rate,sale_price */
fields?: string;
locale_site?: AE_Locale_Site;
page_no?: number;
page_size?: number;
/** Start time, PST time */
start_time: string;
/** Order status: Payment Completed(Buyer paid successfully), Buyer Confirmed Receipt(This status only change when:Buyer confirms receipt and settlement task begins which is manually executed by our operation team), Completed Settlement(Orders have been verified and commission has been paid), Invalid(Orders will not be settled including buyer refunds, order risks, antispam/penalty appeal failed, antispam/penalty appeal overdue, order not settled being over 180 days apart from the Completed Payment Time (such as in abnormal state like dispute), etc.) */
status: string;
}
interface Affiliate_Order_List {
total_page_no: number;
total_record_count: number;
current_page_no: number;
current_record_count: number;
orders: Affiliate_Order_Details[];
}
interface Affiliate_Order_List_Result {
aliexpress_affiliate_order_list_response: {
resp_result: {
result: Affiliate_Order_List;
resp_code?: number;
resp_msg?: string;
};
};
}
/**
* AFFILIATE API
* GET ORDER LIST BY INDEX
*/
interface Affiliate_Order_List_ByIdx_Params {
/** The type of time you are querying: Payment Completed Time(The time of payment for the order), Buyer Confirmed Receipt Time(The time when the buyer confirms receipt) Completed Settlement Time(The time when commission is paid into Account Balance) */
time_type?: string;
/** API signature */
app_signature?: string;
/** End time, PST time */
end_time: string;
/** Respond parameter list. eg: commission_rate,sale_price */
fields?: string;
page_size?: number;
/** Start time, PST time */
start_time: string;
/** Order status: Payment Completed(Buyer paid successfully), Buyer Confirmed Receipt(This status only change when:Buyer confirms receipt and settlement task begins which is manually executed by our operation team), Completed Settlement(Orders have been verified and commission has been paid), Invalid(Orders will not be settled including buyer refunds, order risks, antispam/penalty appeal failed, antispam/penalty appeal overdue, order not settled being over 180 days apart from the Completed Payment Time (such as in abnormal state like dispute), etc.) */
status: string;
/** Query index start value: if not passed, You can only check the first page */
start_query_index_id?: string;
}
interface Affiliate_Order_List_ByIdx {
min_query_index_id: string;
max_query_index_id: string;
current_record_count: number;
orders: Affiliate_Order_Details[];
}
interface Affiliate_Order_List_ByIdx_Result {
aliexpress_affiliate_order_listbyindex_response: {
resp_result: {
result: Affiliate_Order_List_ByIdx;
resp_code?: number;
resp_msg?: string;
};
};
}
/**
*
* DROPSHIPPER API
* RECOMMENDED PRODUCTS
*
*/
interface DS_Recommended_Products_Params {
country?: string;
/**
* @description target currency:USD, GBP, CAD, EUR, UAH, MXN, TRY, RUB, BRL, AUD, INR, JPY,
*/
target_currency?: AE_Currency;
/**
* @description target language:EN,RU,PT,ES,FR,ID,IT,TH,JA,AR,VI,TR,DE,HE,KO,NL,PL,MX,CL,IN
*/
target_language?: AE_Language;
/**
* @description record count of each page, 1 - 50
*/
page_size?: string;
page_no?: string;
sort?: AE_Sort_Promo_Filter;
category_id?: string;
feed_name: string;
}
interface DS_Recommended_Products_Result {
aliexpress_ds_recommend_feed_get_response: Affiliate_Base_Products_Cursor_Response;
}
/**
* DROPSHIPPER API
* FEEDNAMES
*/
interface DS_Feedname_Params extends Affiliate_Categories_Params {
}
interface DS_Feedname_Result {
aliexpress_ds_feedname_get_response: Affiliate_Featuredpromo_Info_Response;
}
/**
* DROPSHIPPER API
* IMAGE SEARCH
*/
interface DS_Image_Search_Params {
/** @description EN,RU,PT,ES,FR,ID,IT,TH,JA,AR,VI,TR,DE,HE,KO,NL,PL,MX,CL,IW,IN */
target_language?: AE_Language;
/** @description USD, GBP, CAD, EUR, UAH, MXN, TRY, RUB, BRL, AUD, INR, JPY, IDR, SEK,KRW */
target_currency?: AE_Currency;
/** @description count of products, max 150. */
product_cnt?: number;
/** @description SALE_PRICE_ASC, SALE_PRICE_DESC, LAST_VOLUME_ASC, LAST_VOLUME_DESC */
sort?: AE_Sort_Filter;
/** @description Ship to Country */
shpt_to?: string;
/** @description image name in fileserver,max size 100 KB */
image_file_bytes: string;
}
interface DS_Image_Search_Result {
aliexpress_ds_image_search_response: {
data: Affiliate_Base_Products_Cursor;
rsp_code: string;
rsp_msg: string;
};
}
/**
* DROPSHIPPER API
* DROPSHIPPER PRODUCT DETAILS
*/
interface DS_Product_Params {
product_id: number;
ship_to_country?: string;
target_currency?: AE_Currency;
target_language?: AE_Language;
}
interface DS_Product_Base_Info {
product_id: number;
category_id: number;
subject: string;
currency_code: AE_Currency;
product_status_type: string;
ws_display: string;
ws_offline_date: string;
gmt_create: string;
gmt_modified: string;
owner_member_seq_long: number;
evaluation_count: string;
avg_evaluation_rating: string;
detail: string;
mobile_detail: string;
}
interface DS_Product_Shipping_Info {
delivery_time: number;
ship_to_country: string;
}
interface DS_Product_Package_Info {
package_type: boolean;
package_length: number;
package_height: number;
package_width: number;
gross_weight: string;
base_unit?: number;
product_unit?: number;
}
interface DS_Product_Store_Info {
store_id: number;
store_name: string;
item_as_described_rating: string;
communication_rating: string;
shipping_speed_rating: string;
}
interface DS_Product_Id_Converter {
main_product_id: number;
sub_product_id: string;
}
interface DS_Product_Multimedia_Videos {
ali_member_id: number;
media_id: number;
media_status: string;
media_type: string;
poster_url: string;
}
interface DS_Product_Multimedia {
ae_video_dtos: DS_Product_Multimedia_Videos[];
image_urls: string;
}
interface DS_Product_SKU_Variation {
sku_stock: boolean;
sku_price: string;
sku_code: string;
ipm_sku_stock: number;
id: string;
currency_code: AE_Currency;
aeop_s_k_u_propertys: DS_Product_SKU_Properties[];
barcode: string;
offer_sale_price: string;
offer_bulk_sale_price: string;
sku_bulk_order: number;
sku_available_stock?: number;
s_k_u_available_stock?: number;
}
interface DS_Product_SKU_Properties {
sku_property_id: number;
sku_property_value: string;
sku_property_name: string;
property_value_id: number;
property_value_id_long: number;
property_value_definition_name?: string;
sku_image?: string;
}
interface DS_Product_Attributes {
attr_name_id: number;
attr_name: string;
attr_value_id: number;
attr_value: string;
attr_value_unit?: string;
attr_value_start?: string;
attr_value_end?: string;
}
interface DS_Product {
ae_item_sku_info_dtos: DS_Product_SKU_Variation[];
ae_item_properties: DS_Product_Attributes[];
ae_item_base_info_dto: DS_Product_Base_Info;
ae_multimedia_info_dto: DS_Product_Multimedia;
package_info_dto: DS_Product_Package_Info;
logistics_info_dto: DS_Product_Shipping_Info;
ae_store_info: DS_Product_Store_Info;
product_id_converter_result: DS_Product_Id_Converter;
}
interface DS_Product_Result {
aliexpress_ds_product_get_response: {
result: DS_Product;
rsp_msg: string;
rsp_code: string;
};
}
/**
*
* ORDER API
* NEW ORDER
*
*/
/**
* Place order params
* @link https://developers.aliexpress.com/en/doc.htm?docId=35446&docType=2
*
*/
interface DS_Place_Order_Params {
ds_extend_request?: string;
/**
* logistics_address
* @description Logistics address information
* @param {String} address Address information
* @param {String} address2 Address extension information
* @param {String} city
* @param {String} contact_person Contact
* @param {String} country
* @param {String} cpf taxpayer identification number
* @param {String} full_name Receiver's full name
* @param {String} locale internationalization locale
* @param {String} mobile_no telephone number
* @param {String} passport_no passport number
* @param {String} passport_no_date passport expiry date
* @param {String} passport_organization passport issuing agency
* @param {String} phone_country Country code where the phone is located
* @param {String} province
* @param {String} tax_number
* @param {String} zip Postal code
* @param {String} foreigner_passport_no foreign tax number (registration card number or passport number is required for Korean foreigners)
* @param {String} is_foreigner whether it is a foreigner
* @param {String} vat_no vat tax number
* @param {String} tax_company company name
* @param {String} location_tree_address_idlocation tree address id
*
* product_items
* @description Product attribute
* @param {Number} product_count Number of Products
* @param {Number} product_id Product id
* @param {String} sku_attr Product sku
* @param {String} logistics_service_name Logistics service name
* @param {String} order_memo User Comments
*
* JSON.stringify the whole thing
*/
param_place_order_request4_open_api_d_t_o: string;
}
interface AE_Product_Item {
logistics_service_name?: string;
order_memo?: string;
product_count: number;
product_id: number;
sku_attr?: string;
}
interface AE_Place_Order_Payment_Params {
promotion?: {
promotion_code?: string;
promotion_channel_info: string;
};
payment?: {
pay_currency?: AE_Currency;
try_to_pay?: "true" | "false";
};
trade_extra_param?: {
business_model?: "retail" | "wholesale";
};
}
interface AE_Logistics_Address {
address: string;
address2?: string;
city?: string;
contact_person?: string;
country?: string;
cpf?: string;
full_name?: string;
locale?: string;
mobile_no?: string;
passport_no?: string;
passport_no_date?: string;
passport_organization?: string;
phone_country?: string;
province?: string;
zip?: string;
tax_number?: string;
foreigner_passport_no?: string;
is_foreigner?: string;
vat_no?: string;
tax_company?: string;
location_tree_address_idlocation?: string;
}
type DS_Place_Order_Error_Message = "B_DROPSHIPPER_DELIVERY_ADDRESS_VALIDATE_FAIL" | "BLACKLIST_BUYER_IN_LIST" | "USER_ACCOUNT_DISABLED" | "PRICE_PAY_CURRENCY_ERROR" | "DELIVERY_METHOD_NOT_EXIST" | "INVENTORY_HOLD_ERROR" | "REPEATED_ORDER_ERROR" | "ERROR_WHEN_BUILD_FOR_PLACE_ORDER" | "A001_ORDER_CANNOT_BE_PLACED" | "A002_INVALID_ZONE" | "A003_SUSPICIOUS_BUYER" | "A004_CANNOT_USER_COUPON" | "A005_INVALID_COUNTRIES" | "A006_INVALID_ACCOUNT_INFO";
interface DS_Place_Order_Result {
aliexpress_trade_buy_placeorder_response: {
result: {
error_code: DS_Place_Order_Error_Message;
error_msg?: string;
is_success: false;
} | {
order_list: number[];
is_success: true;
};
};
}
/**
*
* ORDER API
* GET ORDER
*
*/
interface DS_Get_Order_Params {
order_id: number;
}
interface DS_Price {
amount: string;
currency_code: AE_Currency;
}
interface DS_Product_Info {
product_id: number;
product_price: DS_Price;
product_name: string;
product_count: number;
}
interface DS_Logistics_Info {
logistics_no: string;
logistics_service: string;
}
interface DS_Store_Info {
store_id: number;
store_name: string;
store_url: string;
}
interface DS_Get_Order {
gmt_create: string;
order_status: AE_Order_Status;
logistics_status: AE_Logistics_Status;
order_amount: DS_Price;
child_order_list: DS_Product_Info[];
logistics_info_list: DS_Logistics_Info[];
store_info: DS_Store_Info;
}
interface DS_Get_Order_Result {
aliexpress_trade_ds_order_get_response: {
result: DS_Get_Order;
rsp_msg: string;
rsp_code: string;
};
}
/**
* DROPSHIPPER API - ORDER
* ORDER QUERY BY INDEX
*/
interface DS_Orders_ByIdx_Params {
/** End time, PST time */
end_time: string;
/** Start time, PST time */
start_time: string;
/** Order status: Payment Completed(Buyer paid successfully), Buyer Confirmed Receipt(This status only change when:Buyer confirms receipt and settlement task begins which is manually executed by our operation team), Completed Settlement(Orders have been verified and commission has been paid), Invalid(Orders will not be settled including buyer refunds, order risks, antispam/penalty appeal failed, antispam/penalty appeal overdue, order not settled being over 180 days apart from the Completed Payment Time (such as in abnormal state like dispute), etc.) */
status: string;
/** Query index start value: if not passed, You can only check the first page */
start_query_index_id?: string;
page_size?: number;
page_no?: number;
}
interface DS_Orders_ByIdx_Order_Details {
publisher_id: number;
estimated_finished_commission: string;
estimated_paid_commission: number;
order_number: number;
is_hot_product: YES_NO;
parent_order_number: number;
publisher_settled_currency: AE_Currency;
category_id: number;
item_title: string;
item_detail_url: string;
item_main_image_url: string;
item_count: number;
created_time: string;
finished_time: string;
item_id: number;
paid_time: string;
is_new_buyer: YES_NO;
ship_to_country: string;
sub_order_id: number;
effect_status: string;
incentive_commission_rate: string;
estimated_incentive_paid_commission: string;
is_affiliate_product: YES_NO;
paid_amount: number;
effect_detail_status: string;
estimated_incentive_finished_commission: string;
commission_rate: string;
finished_amount: string;
order_id: number;
}
interface DS_Orders_ByIdx {
current_record_count: number;
min_query_index_id: string;
max_query_index_id: string;
orders: DS_Orders_ByIdx_Order_Details[];
current_page_no: number;
}
interface DS_Orders_ByIdx_Result {
aliexpress_ds_commissionorder_listbyindex_response: {
result: DS_Orders_ByIdx;
rsp_code: number;
rsp_msg: string;
};
}
/**
* DROPSHIPPING API
* ORDER SUBMIT
*/
interface DS_Order_Submit_Params {
/** AE product ID */
ae_product_id: string;
/** Off-site payment time, GMT time, format YYYYMMDD:HHMMSS */
paytime: string;
/** AE order id */
ae_orderid: string;
/** SKU sales amount outside the station, to 2 decimal places */
product_amount: string;
/** Order sales amount outside the station, keep 2 decimal places */
order_amount: string;
/** AE product SKU information, SKU key-value pair: "200000182:193;200007763:201336100" */
ae_sku_info: string;
/** Commodity site url */
product_url: string;
}
interface DS_Order_Submit_Result {
aliexpress_ds_member_orderdata_submit_response: {
result: boolean;
rsp_msg: string;
rsp_code: number;
};
}
/**
* DROPSHIPPING API
* ADD DROPSHIPPING INFO
*/
interface DS_Add_Info_Arguments {
/** Extended Information */
extend_info?: Record<string, string | number | boolean>;
/** shop address */
store_url?: string;
/** user signature */
app_signature?: string;
}
interface DS_Add_Info_Params {
param0: string;
}
interface DS_Add_Info_Result {
aliexpress_ds_add_info_response: {
result: boolean;
result_msg: string;
result_code: number;
};
}
/**
*
* SHIPPING API
* SHIPPING INFO
*
*/
interface DS_Shipping_Info_Arguments {
sku_id?: string;
city_code?: string;
country_code: string;
product_id: number;
product_num: number;
province_code?: string;
send_goods_country_code: string;
price?: string;
price_currency?: AE_Currency;
}
interface DS_Shipping_Info_Params {
/**
* Get the support logistics info of a product, provide for dropshipping develeopers.
*
* @param {String} product_id Product ID
* @param {String} city_code City code
* @param {String} country_code National code
* @param {String} product_num Number of Products
* @param {String} province_code Province code
* @param {String} send_goods_country_code Shipping country code
* @param {String} price price
* @param {String} price_currency Commodity price currency
*
* Apply JSON.stringify to pass params
*/
param_aeop_freight_calculate_for_buyer_d_t_o: string;
}
interface DS_Freight_Info {
amount: number;
cent: number;
currency_code: AE_Currency;
}
interface DS_Shipping_Details {
error_code: number;
estimated_delivery_time: string;
freight: DS_Freight_Info;
service_name: string;
tracking_available: "true" | "false";
}
type DS_Shipping_Info_Response = {
success: true;
aeop_freight_calculate_result_for_buyer_d_t_o_list: DS_Shipping_Details[];
} | {
success: false;
error_desc: string;
};
interface DS_Shipping_Info_Result {
aliexpress_logistics_buyer_freight_calculate_response: {
result: DS_Shipping_Info_Response;
};
}
/**
*
* SHIPPING API
* TRACKING INFO
*
*/
/**
* Dropshipper query logistics tracking information
*
* @param {String} logistics_no Logistics tracking number
* @param {String} origin Order origin to be queried. The origin of the AE order is “ESCROW”.
* @param {String} out_ref Order ID to be queried by the user
* @param {String} service_name Logistics service KEY
* @param {String} to_area Countries for receiving goods, DZ
*/
interface DS_Tracking_Info_Params {
logistics_no: string;
origin: string;
out_ref: string;
service_name: string;
to_area: string;
}
interface DS_Tracking_Event {
event_desc: string;
signed_name: string;
status: string;
address: string;
event_date: string;
}
type DS_Tracking_Info_Response = {
result_success: true;
details: DS_Tracking_Event[];
official_website: string;
} | {
result_success: false;
error_desc: string;
};
interface DS_Tracking_Info_Result {
aliexpress_logistics_ds_trackinginfo_query_response: DS_Tracking_Info_Response;
}
/**
* DROPSHIPPER API
* FREIGHT CALCULATION
*/
interface DS_Freight_Calculation_Arguments {
product_id: number;
product_num: number;
sku_id: string;
country_code: string;
province_code?: string;
city_code?: string;
send_goods_country_code?: string;
price?: string;
price_currency?: AE_Currency;
}
interface DS_Freight_Calculation_Params {
aeopFreightCalculateForBuyerDTO: string;
}
interface DS_Freight_Calculation_Info {
cent: string;
currency: Record<string, string>;
currency_code: AE_Currency;
}
interface DS_Freight_Calculation {
shipping_method: string;
service_name: string;
estimated_delivery_time: string;
freight: DS_Freight_Calculation_Info;
tracking_available: "true" | "false";
}
type DS_Freight_Calculation_Response = {
aeop_freight_calculate_result_for_buyer_dtolist: DS_Freight_Calculation[];
success: true;
} | {
success: false;
error_desc: string;
};
interface DS_Freight_Calculation_Result {
aliexpress_logistics_buyer_freight_get_response: {
result: DS_Freight_Calculation_Response;
request_id: string;
};
}
/**
* DROPSHIPPER API
* CATEGORIES
*/
interface DS_Categories_Result {
aliexpress_ds_category_get_response: {
resp_result: {
resp_code: number;
resp_msg: string;
result: Affiliate_Categories;
};
};
}
interface AES_Base_Access_Token_Result {
account_id: string;
seller_id: string;
user_id: string;
sp: string;
access_token: string;
refresh_token: string;
expires_in: number;
expire_time: number;
refresh_token_valid_time: number;
refresh_expires_in: number;
locale: string;
}
interface AES_Access_Token_Result extends AES_Base_Access_Token_Result {
havana_id: string;
user_nick: string;
account: string;
account_platform: string;
}
/**
* SYSTEM SERVICES
* GENERATE SECURITY TOKEN
*/
interface AES_Generate_Security_Token_Params {
code: string;
uuid?: string;
}
interface AES_Generate_Security_Token_Result extends AES_Base_Access_Token_Result {
}
/**
* SYSTEM SERVICES
* GENERATE ACCESS TOKEN
*/
interface AES_Generate_Token_Params extends AES_Generate_Security_Token_Params {
}
interface AES_Generate_Token_Result extends AES_Access_Token_Result {
}
/**
* SYSTEM SERVICES
* REFRESH SECURITY TOKEN
*/
interface AES_Refresh_Security_Token_Params extends AES_Refresh_Token_Params {
}
interface AES_Refresh_Security_Token_Result extends AES_Access_Token_Result {
}
/**
* SYSTEM SERVICES
* REFRESH ACCESS TOKEN
*/
interface AES_Refresh_Token_Params {
refresh_token: string;
}
interface AES_Refresh_Token_Result extends AES_Access_Token_Result {
}
/**
* Represents the result of an asynchronous operation that can either succeed or fail.
* @template T The type of data returned on success
*/
type Result<T> = Promise<SuccessResult<T> | ErrorResult>;
/**
* Represents a successful operation result
* @template T The type of data returned
*/
type SuccessResult<T> = {
/** Indicates the operation was successful */
ok: true;
/** The successful operation's returned data */
data: T;
};
/**
* Represents a failed operation result
*/
type ErrorResult = {
/** Indicates the operation failed */
ok: false;
/** Human-readable error message */
message: string;
/** Unique identifier for the request, useful for debugging */
request_id?: string;
/** Detailed API error response, if available */
error_response?: ErrorResponse;
/** JavaScript Error object, if available */
error?: Error;
};
type ErrorType = 'ISV' | 'SYSTEM' | 'ISP';
interface ErrorResponse {
/**
* Represents the type of error that occurred from AliExpress Open Platform
* - SYSTEM: API platform error
* - ISV: Business data error
* - ISP: Backend service error
* @see {@link https://openservice.aliexpress.com/doc/doc.htm?nodeId=27493&docId=118729#/?docId=1372 AliExpress Error Codes Documentation}
*/
type?: ErrorType;
code?: string;
sub_code?: string;
msg?: string;
sub_msg?: string;
request_id?: string;
[key: string]: string | undefined;
}
/**
* Base client for AliExpress API interactions.
*
* This class provides the core functionality for authenticating, signing, and sending
* requests to AliExpress API endpoints. It handles the complexities of the AliExpress
* authentication protocol, including request signing, parameter formatting, and
* response parsing.
*
* The class supports both older "TOP" API endpoints and newer "OP" API routes,
* automatically determining the correct URL format and parameter handling based on
* the method name.
*/
declare class AEBaseClient implements AE_Base_Client {
readonly app_key: string;
readonly app_secret: string;
readonly session: string;
protected readonly format = "json";
protected readonly migrated_apis_url = "https://api-sg.aliexpress.com/sync";
protected readonly new_apis_url = "https://api-sg.aliexpress.com/rest";
protected readonly sign_method = "sha256";
constructor(init: AE_Base_Client);
/**
* 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
*/
protected sign(params: any): string;
/**
* 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
*/
protected assemble<T extends PublicParams>(params: T): string;
/**
* 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
*/
protected call<T extends PublicParams, K>(params: T): Result<K>;
/**
* 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
*/
protected execute<K extends AE_API_NAMES>(method: K, params: AliexpressMethod<K>["params"]): Result<AliexpressMethod<K>["result"]>;
/**
* 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<TData extends Record<string, string | number | boolean>, TResponse>(method: string, params: TData): Result<TResponse>;
}
/**
* Client for AliExpress System API operations.
*
* This client provides methods for token management and authentication with
* the AliExpress API system. It extends the base client with specialized
* methods for generating and refreshing access tokens, which are required
* for authenticated access to other API endpoints.
*
* The client serves as a foundation for other specialized clients and can
* be used directly for authentication operations.
*
* @extends AEBaseClient Base client with core API interaction capabilities
*/
declare class AESystemClient extends AEBaseClient {
constructor(init: AE_Base_Client);
/**
* 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: AES_Generate_Security_Token_Params): Promise<{
ok: false;
message: string;
request_id?: string;
error_response?: ErrorResponse;
error?: Error;
} | {
ok: true;
data: AES_Generate_Security_Token_Result;
}>;
/**
* 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