How to Scrape Tokopedia Data: Complete Guide for 2026
Tutorials

How to Scrape Tokopedia Data: Complete Guide for 2026

Learn how to scrape Tokopedia safely and efficiently using Python, Node.js, and AlterLab's API. Covers anti-bot handling, structured extraction, pricing, and best practices for 2026.

H
Herald Blog Service
4 min read
4 views

AlterLab handles this automaticallyscrape any URL with one API call. No infrastructure required.

Try it free

This guide covers extracting publicly accessible data. Always review a site's robots.txt and Terms of Service before scraping.

TL;DR

To scrape Tokopedia in 2026, use AlterLab's API with Python or Node.js, start at tier T1 and let the service auto‑escalate to T3/T4 for anti‑bot pages, extract public product data via CSS selectors or Cortex structured extraction, and respect rate limits and robots.txt. The entire flow takes under 10 lines of code.

Why collect e-commerce data from Tokopedia?

Tokopedia hosts millions of product listings across electronics, fashion, and home goods, making it a rich source for:

  • Price monitoring: Track competitor pricing fluctuations for dynamic repricing strategies.
  • Market research: Identify trending categories and emerging product niches by analyzing listing volume and description keywords.
  • Data analysis: Build datasets for demand forecasting, sentiment analysis from reviews, or inventory planning.

These use cases rely on publicly visible product cards, prices, ratings, and availability—all accessible without authentication.

Technical challenges

E‑commerce sites like Tokopedia deploy layered anti‑bot protections to safeguard their infrastructure. Common mechanisms include:

  • Request rate limiting per IP
  • Header validation (User‑Agent, Accept, Referer)
  • JavaScript‑rendered content that hides data behind XHR calls
  • Occasional challenge pages (e.g., Cloudflare Turnstile) for suspicious traffic

Raw requests.get() or fetch() often returns empty HTML or a challenge page. AlterLab's Smart Rendering API automatically detects failures and promotes the request through tiers T1–T5, applying proxy rotation, realistic headers, and headless Chrome when needed. You only pay for the tier that ultimately succeeds.

99.2%Success Rate
1.2sAvg Response
$0.002Per Request (T3)

Quick start with AlterLab API

Begin by installing the SDK and making a basic request to a public Tokopedia product page. AlterLab handles retries, proxy rotation, and tier escalation behind the scenes.

Python

Python
import alterlab

client = alterlab.Client("YOUR_API_KEY")
response = client.scrape("https://tokopedia.com/example-product")
print(response.text[:500])  # First 500 chars of HTML

Node.js

JAVASCRIPT
import { AlterLab } from "alterlab";

const client = new AlterLab({ apiKey: "YOUR_API_KEY" });
const response = await client.scrape("https://tokopedia.com/example-product");
console.log(response.text.slice(0, 500));

cURL

Bash
curl -X POST https://api.alterlab.io/v1/scrape \
  -H "X-API-Key: YOUR_KEY" \
  -d '{"url": "https://tokopedia.com/example-product"}'

See the Getting started guide for SDK installation and authentication details.

Extracting structured data

Once you have the HTML, parse the visible product fields. Tokopedia's product cards use predictable class names (subject to change; always inspect the live page). Below are CSS selectors for common data points:

Data pointCSS selector (example)Attribute
Product titlediv[data-testid="spnSRPProdName"]innerText
Pricediv[data-testid="lblSRPPrice"]innerText (strip currency)
Ratingdiv[data-testid="lblSRPRating"]innerText
Image URLimg[data-testid="lllSRPImage"]src
Availabilityspan[data-testid="lblSRPStock"]innerText

In Python with BeautifulSoup:

Python
from bs4 import BeautifulSoup
import re

soup = BeautifulSoup(response.text, "html.parser")
title = soup.select_one("div[data-testid='spnSRPProdName']").get_text(strip=True)
price_text = soup.select_one("div[data-testid='lblSRPPrice']").get_text(strip=True)
price = float(re.sub(r"[^\d.]", "", price_text))
rating = float(soup.select_one("div[data-testid='lblSRPRating']").get_text(strip=True))

Node.js with cheerio follows the same pattern.

Structured JSON extraction with Cortex

For typed output without manual parsing, use AlterLab's Cortex extraction API. Provide a JSON Schema describing the desired shape, and AlterLab returns validated data.

Python
import alterlab

client = alterlab.Client("YOUR_API_KEY")
result = client.extract(
    url="https://tokopedia.com/example-product",
    schema={
        "type": "object",
        "properties": {
            "title": {"type": "string"},
            "price": {"type": "number"},
            "rating": {"type": "number"},
            "description": {"type": "string"}
        },
        "required": ["title", "price"]
    }
)
print(result.data)  # {'title': '...', 'price': 125000.0, 'rating': 4.5, 'description': '...'}

Cortex internally runs a headless browser, waits for network idle, and uses an LLM to locate fields—no CSS selectors required. This is especially useful when Tokopedia updates its class names.

Try it yourself

Try scraping Tokopedia with AlterLab

Cost breakdown

AlterLab's pricing is request‑based and tiered. The table below shows the cost per request and per 1,000 requests. For Tokopedia, start at T1; most product pages will promote to T3 (Stealth) due to anti‑bot measures, while pages with heavy client‑side rendering may reach T4 (Browser).

TierUse CaseCost per RequestCost per 1,000Requests per $1
T1 — CurlStatic HTML, no JS needed$0.0002$0.205,000
T2 — HTTPStandard pages with headers$0.0003$0.303,333
T3 — StealthProtected pages, anti-bot active$
Share

Was this article helpful?

Frequently Asked Questions

Scraping publicly accessible data is generally permissible under rulings like hiQ v LinkedIn, but you must review Tokopedia's robots.txt and Terms of Service, apply rate limiting, and avoid private or login‑gated information. Compliance remains the scraper's responsibility.
Tokopedia employs standard anti‑bot measures such as request rate checks, header validation, and occasional JavaScript challenges. Raw HTTP requests often fail; AlterLab handles these via auto‑escalating tiers, proxy rotation, and headless browser rendering when needed.
Costs range from $0.0002 per request for static HTML (T1) to $0.004 for full JavaScript rendering (T4). AlterLab auto‑escalates only when a lower tier fails, so you pay for the tier that succeeds. See the pricing table for per‑1k request rates.