How to search Aliexpress products by image thanks to Halios-data's API in Javascript/NodeJS

The purpose of this article is to explain how you can search products from aliexpress with an image URL.

We will use nodeJS to consume the API

This feature can be interesting for your dropshipping website by integrating a more user-friendly search.

You also can download the project from git

Search the products with the API

Create an account to RapidAPI

Today, you need to create an account to RAPIDAPI to consume the API, but don't worry, you can use your Google or Github account ;).

Subscribe to the API

After the login, you are generally redirected to the API hub. Else click here

You can test the API for free with 5 requests per month for search products by image else 500 for other endpoints. Click on the subscribe button and choose the Basic plan.

API Using

To communicate with the API, we will use Axios during this example.

First, install it thanks to npm. We implement the communication with the API in the app.service.ts with Axios lib inside the service.

We inject the library at the top of our service.

import { Axios } from 'axios';

We add the method that communicates with the API and returns the products from an image URL.

I call this one getData, and I inject in the method a parameter URL.

getData(url: string): { message: string } { let products; return products; }

In order to realize the communication with the API, I'm creating a private method with a parameter.

private async getProductsFromImage(url: string) {

In the method, I'm implementing the communication with the API.

private async getProductsFromImage(url: string) { try { var aliexpressProducts = await this.axios.request({ method: 'GET', url: '', params: { url: url }, headers: { 'x-rapidapi-host': '', 'x-rapidapi-key': 'YOUR_TOKEN' } }) } catch (e) { throw e; } return JSON.parse(; }

And now, in the public method, I can call my private method with the image URL communicated by the controller.

async getData(url: string): Promise<any> { let products; products = await this.getProductsFromImage(url) return products; }

It is now enough to communicate the URL of the controller to the service.

async getData(@Query('url') url) { return await this.appService.getData(url); }

Consume the API

Now I can ask my API to return the products with an image.


And the API returns

{ "data": { "dto": { "categorys": [ { "id": 0, "name": "Apparel", "selected": true }, { "id": 3, "name": "Luggage & Bags", "selected": false }, { "id": 4, "name": "Shoes", "selected": false }, { "id": 88888888, "name": "Others", "selected": false } ], "items": [ { "imgWidth": 350, "productId": 1005001710015939, "subject": "Autumn Winter Men`s Thick Warm Corduroy Pants Fleece Trousers Male Casual Business Style Long Jeans Men", "marketingPrice": { "appPrice": { "discount": 0, "price": { "currency": "USD", "formatedAmount": "US $18.49", "value": 18.49 } }, "bigSalePrice": null, "pcPrice": null }, "logistics": null, "debugInfo": null, "promotionTag": null, "union": null, "plusInfo": null, "type": "ImageSearchProduct", "p4p": null,

Thank you and good scraping :)

36 views0 comments

Discover Halios-Data solution for the web scraping

More Halios-Data

Never miss an update

Thanks for submitting!