A simple and type-safe SDK for Aliexpress (system tools, dropshipping and affiliate) APIs.
Aliexpress launched a new open platform to consume their APIs. They fully migrated and upgraded their services from the old Taobao Open Platform to the new Open Platform for International Developers. The issue is, with this update, they have yet to release a Node.js SDK.
This library is an unofficial and simple SDK that can do the following:
- Compose a request, generate an encryption (method signature) and interprete the response.
- Pass the right parameters for your API call with type safe methods.
- Currently supports the system tools for authentication, Affiliate API and Dropshipping API.
# using npm
npm i ae_sdk
# using pnpm
pnpm add ae_sdk
# using yarn
yarn add ae_sdk
Before you can start using this SDK you should start with the following steps:
You must have an Aliexpress account or create one, and then register as a developer through this link. For more details.
After creating your developer account, you can start registering a new applicationon by following the steps details in the following link.
Once your application is registered, the app_key
and app_secret
are assigned to the application automatically. These parameters must be included in every AE API request.
For more details on how to retrieve them, visit.
In order to access Aliexpress sellers’ business data, the application needs to get the authorization from sellers, and you need to guide them to complete the flow of “using Aliexpress seller account to log in and authorize”. Follow the steps detailed in this link to get your access token. It must included in every AE API request.
Using the dropshipping client in this example
After retrieving the required parameters to initialize a new client, you do the following:
import { DropshipperClient } from "ae_sdk";
const client = new DropshipperClient({
app_key: "123",
app_secret: "123456abcdef",
session: "oauth_access_token",
});
With your client initialized, you're all set up. For example, you can retrieve a certain product's details:
await client.productDetails({
product_id: 1005004043442825,
ship_to_country: "DZ",
target_currency: "USD",
target_language: "en",
});
All API calls, if successfull will return a boolen ok
and a data
with the response body.
The following is an example response for the above API request:
{
"ok": true,
"data": {
"aliexpress_ds_product_get_response": {
"result": {},
"rsp_code": 200,
"rsp_msg": "Call succeeds",
"request_id": "..."
}
}
}
If not successfull, you will get:
{
"ok": false,
"message": "...",
"request_id": "...",
"error_response": {} /** Entire AE API error response, if available */,
"error": {} /** JS Error object, if available */
}
If you wish to call a different Aliexpress API that is not available in the current version. You can do the following:
const result = await client.callAPIDirectly("aliexpress.api.endpoint", {
[string]: string | number | boolean,
});
In order to generate an affiliate link for Aliexpress products that are registered in the affiliate program.
await client.generateAffiliateLinks({
// 0 for a normal link, 2 for hot link which has hot product commission
promotion_link_type: 0 | 2,
// original aliexpress product's link
source_values: "...",
tracking_id: "...",
app_signature: "...",
});
To search for high commission affiliate products.
await client.getHotProducts({
app_signature: "...",
keywords: "watch",
page_no: 1,
page_size: 50,
platform_product_type: "ALL",
ship_to_country: "US",
sort: "SALE_PRICE_ASC",
target_currency: "USD",
target_language: "EN",
tracking_id: "...",
});
Get the shipping details for any product.
await client.freightInfo({
country_code: "DZ",
send_goods_country_code: "CN",
product_id: 123456,
product_num: 1,
});
In order to place an order.
await client.createOrder({
logistics_address: {
address: "...",
city: "...",
country: "DZ",
full_name: "Bou Ben",
mobile_no: "0555 66 77 88",
phone_country: "+213",
zip: "16000",
},
product_items: [
{
logistics_service_name: "...",
order_memo: "This is a dropshipping order.",
product_count: 1,
product_id: 123,
sku_attr: "...",
},
],
});