
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.
AlterLab handles this automatically — scrape any URL with one API call. No infrastructure required.
Try it freeThis 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.
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
import alterlab
client = alterlab.Client("YOUR_API_KEY")
response = client.scrape("https://tokopedia.com/example-product")
print(response.text[:500]) # First 500 chars of HTMLNode.js
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
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 point | CSS selector (example) | Attribute |
|---|---|---|
| Product title | div[data-testid="spnSRPProdName"] | innerText |
| Price | div[data-testid="lblSRPPrice"] | innerText (strip currency) |
| Rating | div[data-testid="lblSRPRating"] | innerText |
| Image URL | img[data-testid="lllSRPImage"] | src |
| Availability | span[data-testid="lblSRPStock"] | innerText |
In Python with BeautifulSoup:
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.
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 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).
| Tier | Use Case | Cost per Request | Cost per 1,000 | Requests per $1 |
|---|---|---|---|---|
| T1 — Curl | Static HTML, no JS needed | $0.0002 | $0.20 | 5,000 |
| T2 — HTTP | Standard pages with headers | $0.0003 | $0.30 | 3,333 |
| T3 — Stealth | Protected pages, anti-bot active | $ |
Was this article helpful?
Frequently Asked Questions
Related Articles

LoopNet Data API: Extract Structured JSON in 2026
Learn how to build a production-ready data pipeline using the AlterLab LoopNet data api to extract structured real-estate JSON without managing proxies or selectors.
Herald Blog Service

How to Scrape MercadoLibre Data: Complete Guide for 2026
Learn how to scrape MercadoLibre data efficiently using Python, Node.js, and AI-powered extraction. Master anti-bot bypass and structured data workflows.
Herald Blog Service

Cost-Effective Agentic Web Workflows: Self-Hosted vs Pay-As-You-Go Scraping APIs for RAG
Compare self-hosted and pay-as-you-go scraping APIs for agentic RAG pipelines. Learn cost, performance, and integration tradeoffs to choose the right approach.
Herald Blog Service
Popular Posts
Recommended

How to Scrape AliExpress: Complete Guide for 2026

Why Your Headless Browser Gets Detected (and How to Fix It)

AlterLab vs Firecrawl: In-Depth Review with Benchmarks & Code Examples

How to Scrape Twitter/X Data: Complete Guide for 2026

How to Scrape Cloudflare-Protected Sites in 2026
Newsletter
Scraping insights and API tips. No spam.
Recommended Reading

How to Scrape AliExpress: Complete Guide for 2026

Why Your Headless Browser Gets Detected (and How to Fix It)

AlterLab vs Firecrawl: In-Depth Review with Benchmarks & Code Examples

How to Scrape Twitter/X Data: Complete Guide for 2026

How to Scrape Cloudflare-Protected Sites in 2026
Stay in the Loop
Get scraping insights, API tips, and platform updates. No spam — we only send when we have something worth reading.
Explore AlterLab
Web Scraping API Resources
Part of the Web Scraping API Documentation cluster
Complete API reference with 5-tier auto-escalation — Curl to challenge resolution.
Pillar pageConfigure Tier 4 browser rendering for SPAs and dynamic content.
Scrape pages behind login using session management.
Real success rates and cost data across all 5 tiers.
MCP Server, Python SDK, and Firecrawl-compatible API for AI agent workflows.