Lazada Search API Across Countries: Compare Prices Without Mixing Currencies

Published October 30, 2026

Aisyah Rahman sells silicone phone cases from Johor Bahru. Before restocking she wanted one answer: which Lazada storefront lists the cheapest plain case? She searched the same keyword on the Malaysia, Singapore and Thailand storefronts, pasted every result into one sheet, and sorted the price column from low to high. The top row became her benchmark, and nothing in the sheet could have told her it was wrong. (Aisyah and her sheet are invented; the response facts below come from a stored search response of this API.)

The sheet that sorted ringgit and baht into one column

Her sorted sheet, with illustrative rows:

sitepricecurrencyrank by raw number
sg3.50SGD1
my12.90MYR2
th36THB3

Sorting ranks the numbers, so Singapore wins and Thailand finishes last. But those are Singapore dollars, ringgit and baht. Apply the placeholder rates used later in this guide (1 SGD = 3.3 MYR = 25 THB, made up for the walkthrough and not a quote) and the order flips: 36 baht is about 1.44 SGD, 12.90 ringgit about 3.91 SGD, and the Singapore row at 3.50 SGD lands in the middle. Under those rates the market that looked most expensive was the cheapest, because a raw min(price) favors whichever currency uses the smallest-looking numbers.

Every row in that sheet had a price and no unit. The search response does carry the unit, so the rebuild keeps it.

Carry site and currency on every row from the first call

The Lazada Product Search API is one GET operation, search-items-by-keywords, at https://api.opendata-api.com/api/project/lazada-api/search-items-by-keywords?key=YOUR_API_KEY. It needs keywords and site, where site is one of my, sg, vn, id, ph or th, one code per request. No browser, slider captcha, seller account or shop login is involved, only an authorized platform key from your dashboard. The key travels in the URL, so keep it out of logs and shared links.

The stored response behind this guide is one Thai search (keywords=t shirt, site=th, page 1). Its envelope had code 200 and msg success, with page, page_size, total_count, start_key, keyword, sort, price_start, price_end and items. All 40 items carried currency set to THB. price was a string on every row, and some had decimals such as 90.26.

import os
import requests
from datetime import datetime, timezone

BASE = "https://api.opendata-api.com/api/project/lazada-api/search-items-by-keywords"
KEY = os.environ["OPENDATA_API_KEY"]  # authorized key from the dashboard, never committed

# Assumption, checked on every response below. Only th/THB appears in the stored response.
EXPECTED = {"my": "MYR", "sg": "SGD", "th": "THB"}


def number(text):
    try:
        return float(text)
    except (TypeError, ValueError):
        return None


def fetch_page(site, keywords, page=1, **bounds):
    params = {"key": KEY, "site": site, "keywords": keywords, "page": page, **bounds}
    resp = requests.get(BASE, params=params, timeout=30)
    if not resp.ok:  # HTTP status first; never log resp.url, it carries the key
        raise RuntimeError(f"{site}: HTTP {resp.status_code}")
    body = resp.json()
    if body.get("code") != 200:  # then the gateway's business status
        raise RuntimeError(f"{site}: code={body.get('code')} msg={body.get('msg')}")
    return body["data"]


def to_rows(site, data):
    fetched_at = datetime.now(timezone.utc).isoformat()
    rows = []
    for item in data["items"]:
        if item["currency"] != EXPECTED[site]:
            raise ValueError(f"{site} returned {item['currency']}, expected {EXPECTED[site]}")
        rows.append({
            "site": site, "item_id": item["item_id"],
            "seller_id": item["shop_info"]["seller_id"],
            "title": item["title"], "currency": item["currency"],
            "price": number(item["price"]), "fetched_at": fetched_at,
        })
    return rows


def cheapest(rows):
    """The guard that would have saved the sheet."""
    currencies = {r["currency"] for r in rows}
    if len(currencies) != 1:
        raise ValueError(f"refusing to compare mixed currencies: {sorted(currencies)}")
    return min((r for r in rows if r["price"] is not None), key=lambda r: r["price"])

HTTP 200 is the first check and the gateway's code the second. EXPECTED is an assumption; the check in to_rows turns a wrong guess into an error on the first call instead of a wrong sheet.

Read price_start and price_end as bounds in each storefront's own money

Both bounds are optional numeric strings, and the endpoint reference describes them as read in the selected storefront's currency. In the unbounded Thai response they came back inside data as empty strings. No bounded query was run for this guide, so the check below is something to run, not a result to quote.

Take Aisyah's "under 20 SGD" window. Pasting price_end=20 into three requests asks for 20 baht, 20 ringgit and 20 Singapore dollars. At the placeholder rates, 20 SGD is about 66 ringgit or 500 baht, so each storefront needs its own bounds and proof they were applied:

RATES = {"as_of": "2026-10-31", "per_sgd": {"SGD": 1.0, "MYR": 3.3, "THB": 25.0}}  # placeholders


def local_window(site, lo_sgd, hi_sgd):
    rate = RATES["per_sgd"][EXPECTED[site]]
    return {"price_start": str(round(lo_sgd * rate)), "price_end": str(round(hi_sgd * rate))}


def outside_window(rows, window):
    lo, hi = float(window["price_start"]), float(window["price_end"])
    return [r for r in rows if r["price"] is not None and not lo <= r["price"] <= hi]


window = local_window("th", 5, 20)
rows = to_rows("th", fetch_page("th", "silicone case", **window))
if outside_window(rows, window):
    raise RuntimeError("bounds were not applied as assumed; read the response before filtering")

item_id belongs to one storefront: match products on a title key

item_id is a string, and in the stored response each id also appears inside that row's product_url on the Thai domain. All 40 ids on the page were distinct. No response on file shows one id on two storefronts, and nothing says the same number means the same product elsewhere. Key every row by (site, item_id) and use the id only to diff snapshots within one storefront.

The seller fields point the same way. In the stored response shop_id was null on all 40 rows, while seller_id was present on all 40, across 34 distinct sellers. To answer which shops sell a keyword, group by seller_id.

Titles are storefront text: 38 of the 40 Thai titles contain Thai script. To compare the same case across countries, match on a Latin model string you control:

import re


def title_key(title, models):
    text = re.sub(r"[^0-9a-z]+", " ", title.lower())
    return next((m for m in models if m in text), None)

Rows where title_key returns None stay out of the comparison, and matches are candidates for a person to confirm.

After: group by currency, then convert with a dated rate table

Convert only after the grouping is explicit, and write the rate date beside every converted number:

def to_sgd(row):
    rate = RATES["per_sgd"].get(row["currency"])
    return None if rate is None or row["price"] is None else row["price"] / rate


def cheapest_per_site(rows):
    best = {}
    for r in rows:
        sgd = to_sgd(r)
        if sgd is not None and (r["site"] not in best or sgd < best[r["site"]]["sgd"]):
            best[r["site"]] = {**r, "sgd": round(sgd, 2), "rate_date": RATES["as_of"]}
    return sorted(best.values(), key=lambda r: r["sgd"])

Aisyah's rebuilt sheet, again with illustrative values:

sitelocal pricecurrencyin SGDrate table date
th36THB1.44placeholder
sg3.50SGD3.50placeholder
my12.90MYR3.91placeholder

Thailand now leads, because the comparison happens in one unit. The local price stays beside the converted one, so a rate move changes only the converted column, while a real price change appears under the same (site, item_id) with a new fetched_at. A storefront with no convertible rows is unknown, never zero, and cannot win.

Give each storefront the pages it has earned

In the stored response page was 1, page_size 40, total_count 33,395 for t shirt on the Thai storefront, and start_key a string. The request takes page only, so start_key is not an input to send back. total_count counts listings for the keyword, a supply signal rather than demand or sales. Pages above 1 were not probed.

Depth should follow what each storefront offers, under a ceiling you pick:

data = fetch_page("th", "silicone case", page=1)
last_page = -(-data["total_count"] // data["page_size"])
pages_to_read = min(3, last_page)  # a storefront with 12 hits earns one page, not three

sort accepts pop, sales, price_up and price_down; only the default pop appears in the stored response. Before treating page 1 of price_up as the cheapest listings, check that its prices ascend. Each page is a request, so three storefronts at three pages each is nine.

Where a country-by-country price table hands off next

With site, currency, a dated rate and a title key on each row, the table can feed other comparison jobs:

Aisyah's next change is small: a currency column she can no longer forget.