Blog › Guides

Find the lowest price on Tokopedia, Shopee and Lazada with Python

Search three marketplaces for the same keyword, keep the cheapest listing from each and get told when the price drops.

Zapi Team
On this page
In short

Each marketplace has a search endpoint that returns items with a name, a URL and a price in rupiah. Call all three, keep the lowest price, and compare it with the last run. One keyword costs 12 Zap a run.

01One response shape for three marketplaces

Tokopedia, Shopee and Lazada each have a search endpoint on Zapi. Their answers share one shape: a data object with an items list, and every item has a name, a url and a price as a plain number in rupiah.

Each one sits under /v1/marketplace:, and only the keyword parameter differs:

MarketplaceEndpointKeywordZap
Tokopediatokopedia/searchq1
Shopeeshopee/searchquery1
Lazadalazada/searchquery10

02Search all three

Set your key as ZAPI_KEY, then run this. It prints the cheapest listing from each marketplace, lowest first.

import os, requests

KEY = os.environ["ZAPI_KEY"]
API = "https://api.zapi.ink/v1/marketplace:"

# endpoint, and the name of its keyword parameter
SEARCH = {
    "Tokopedia": ("tokopedia/search", "q"),
    "Shopee": ("shopee/search", "query"),
    "Lazada": ("lazada/search", "query"),
}

def cheapest(keyword):
    found = []
    for shop, (path, param) in SEARCH.items():
        r = requests.get(API + path, params={param: keyword},
                         headers={"x-api-key": KEY}, timeout=120)
        r.raise_for_status()
        items = [i for i in r.json()["data"]["items"] if i.get("price")]
        if items:
            low = min(items, key=lambda i: i["price"])
            found.append((low["price"], shop, low["name"], low["url"]))
    return sorted(found)

for price, shop, name, url in cheapest("usb-c charger 65w"):
    print(f"Rp{price:,}  {shop:<10} {name[:50]}  {url}")

03Remember the last price

To get told when the price drops, keep the lowest price in a small file and compare on the next run.

import json, pathlib

KEYWORD = "usb-c charger 65w"
SEEN = pathlib.Path("lowest.json")

last = json.loads(SEEN.read_text()) if SEEN.exists() else {}
price, shop, name, url = cheapest(KEYWORD)[0]

if price < last.get(KEYWORD, float("inf")):
    print(f"New low: Rp{price:,} at {shop}: {url}")

last[KEYWORD] = price
SEEN.write_text(json.dumps(last))

Run it once a day from cron, a scheduled GitHub Action or any job runner, and swap the print for a message to Telegram, Slack or email.

04What it costs

Tokopedia and Shopee searches cost 1 Zap each; Lazada’s costs 10, since it needs a full browser. So one keyword is 12 Zap a run.

Checked once a day, that is about 360 Zap a month per keyword. One keyword fits the Free plan’s 600 Zap; the Pro plan’s 25,000 Zap covers about 69. Running the same search again within a few minutes returns the cached answer, which costs 1 Zap.

Compare like with like

Search results mix new and used items, bundles and accessories. Use a specific keyword, or filter the items by name, before you trust the lowest price.

05Next steps

To follow specific products rather than a keyword, the product endpoints take a product URL and return its current price. Price Monitoring walks through that setup, and Zapi for Python covers keys, errors and retries.

PythonMarketplacePrice monitoring
Zapi Team

We build Zapi and keep its sources running, so you get the same JSON every day.

Build on the data you just read about.

Free key, 600 Zap a month and one response shape for every source.