API Integration Guide
Complete documentation for integrating with the Magpie Scraping API.
๐ Authentication
All endpoints require a Bearer token in the Authorization header:
Authorization: your-api-token
Contact us for trial access or manage your token in the dashboard.
โณ Approval Flow
Jobs for Variant Sold, Merchant Items and Search Items endpoints go through manual approval:
- You submit a job โ Status:
AWAITING_APPROVAL - Our team reviews and approves (within 24 hours)
- Job starts processing โ Status:
PROCESSING - Results ready โ Status:
COMPLETEDorPARTIAL_COMPLETE
Note: PDP tier 2, Tokopedia PDP, and Blibli PDP do NOT require approval - tasks are processed immediately.
1. Variant Sold
Batch scraping for Shopee product variant and sales data. Up to 50,000 items per request.
Supported regions: ID ยท SG ยท TH ยท PH ยท MY ยท VN ยท TW
๐ Endpoint
POST /shopee/variant_sold_v1/submit
GET /shopee/variant_sold_v1/retrieve/{job_id}
GET /shopee/variant_sold_v1/download/{job_id}
๐ฅ Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
country | string | Yes | Country code: id, sg, th, ph, my, vn, tw |
items | array | Yes | Array of objects with item_id and shop_id (max 50,000) |
๐ป Code Examples
# Submit Job
curl -X POST "https://nest-api.magpieiq.com/shopee/variant_sold_v1/submit" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"country": "id",
"items": [
{"item_id": 13490493252, "shop_id": 651735813},
{"item_id": 12345678901, "shop_id": 987654321}
]
}'
# Poll Status
curl "https://nest-api.magpieiq.com/shopee/variant_sold_v1/retrieve/{job_id}" \
-H "Authorization: Bearer YOUR_API_TOKEN"
# Download Results
curl "https://nest-api.magpieiq.com/shopee/variant_sold_v1/download/{job_id}" \
-H "Authorization: Bearer YOUR_API_TOKEN"
View Python Example
import requests
import time
API_HOST = "https://nest-api.magpieiq.com"
headers = {
"Authorization": "Bearer YOUR_API_TOKEN",
"Content-Type": "application/json"
}
# 1. Submit Job
payload = {
"country": "id",
"items": [
{"item_id": 13490493252, "shop_id": 651735813},
{"item_id": 12345678901, "shop_id": 987654321}
]
}
response = requests.post(f"{API_HOST}/shopee/variant_sold_v1/submit", json=payload, headers=headers)
job_id = response.json()["job_id"]
print(f"Job submitted: {job_id}")
# 2. Poll until complete
while True:
status_resp = requests.get(f"{API_HOST}/shopee/variant_sold_v1/retrieve/{job_id}", headers=headers)
status = status_resp.json()["status"]
print(f"Status: {status}")
if status in ["COMPLETED", "PARTIAL_COMPLETE", "FAILED"]:
break
time.sleep(30)
# 3. Download results
download_resp = requests.get(f"{API_HOST}/shopee/variant_sold_v1/download/{job_id}", headers=headers)
print(download_resp.json())
Behavior
- Cost: 10 credits per item
- Approval: Required (24h timeout)
- Batching: Items are chunked into batches of 50 for processing
- Results: Merged into a single JSON file per job
Result Example
Variant Sold JSON Click to expand
2. PDP tier 2
Extended product details from Shopee product detail page. Single task per request. No Approval Required
Supported regions: ID ยท SG ยท TH ยท PH ยท MY ยท VN
๐ Endpoint
POST /shopee/get_pc/submit
GET /shopee/get_pc/retrieve/{task_id}
๐ฅ Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Shopee product URL (e.g., https://shopee.co.id/product/{shop_id}/{item_id}) |
๐ป Code Examples
# Submit Task
curl -X POST "https://nest-api.magpieiq.com/shopee/get_pc/submit" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"url": "https://shopee.co.id/product/34907167/40869177342"}'
# Retrieve Result (poll until status is "completed")
curl "https://nest-api.magpieiq.com/shopee/get_pc/retrieve/{task_id}" \
-H "Authorization: Bearer YOUR_API_TOKEN"
View Python Example
import requests
import time
API_HOST = "https://nest-api.magpieiq.com"
headers = {"Authorization": "Bearer YOUR_API_TOKEN", "Content-Type": "application/json"}
# Submit
resp = requests.post(f"{API_HOST}/shopee/get_pc/submit",
json={"url": "https://shopee.co.id/product/34907167/40869177342"}, headers=headers)
task_id = resp.json()["task_id"]
# Poll until ready
while True:
result = requests.get(f"{API_HOST}/shopee/get_pc/retrieve/{task_id}", headers=headers).json()
if result.get("status") == "completed":
print(result["data"])
break
time.sleep(5)
โก Behavior
- Cost: 8 credits per request
- Approval: NOT required - immediate processing
- Processing: Single task processing
- Results: Full product detail page data including attributes, models, description
Result Example
PDP tier 2 JSON Click to expand
3. PDP tier 2 Bulk CSV
Submit many PDP tier 2 products as CSV and download one CSV or JSONL result file. No Approval Required
CSV columns: region,shop_id,item_id
๐ Endpoint
POST /shopee/get_pc_bulk/submit
GET /shopee/get_pc_bulk/retrieve/{task_id}
๐ป Code Example
# Submit CSV (result_format defaults to csv; jsonl is faster for large batches)
curl -X POST "https://nest-api.magpieiq.com/shopee/get_pc_bulk/submit" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "[email protected];type=text/csv" \
-F "rescrape=false" \
-F "result_format=jsonl"
# Poll until status is "completed"
curl "https://nest-api.magpieiq.com/shopee/get_pc_bulk/retrieve/{task_id}" \
-H "Authorization: Bearer YOUR_API_TOKEN"
# Download completed result
curl -L -o result.jsonl.gz "{download_url}"
Completed Result Example
{
"status": "completed",
"total": 216,
"success": 216,
"failed": 0,
"pending": 0,
"progress": 1,
"download_url": "https://storage.googleapis.com/.../result.jsonl.gz?X-Goog-Signature=...",
"result_gcs_path": "gs://magpie-universe-export/.../result.jsonl.gz",
"export": {
"signed_url": "https://storage.googleapis.com/.../result.jsonl.gz?X-Goog-Signature=...",
"compressed": true
}
}
Use download_url in the UI/client. result_gcs_path is for debugging.
4. Search / Category Items
Scrape all products from Shopee search or category pages. Up to 50 URLs per request.
Supported regions: ID ยท SG ยท TH ยท PH ยท MY ยท VN ยท TW
๐ Endpoint
POST /shopee/search-items/submit
GET /shopee/search-items/retrieve/{job_id}
๐ฅ Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
urls | array | Yes | Array of Shopee search/category URLs (max 50) |
๐ Supported URL Formats
- Search:
https://shopee.co.id/search?keyword=iphone - Category:
https://shopee.co.id/Elektronik-cat.11044070
๐ป Code Examples
# Submit Job
curl -X POST "https://nest-api.magpieiq.com/shopee/search-items/submit" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"urls": [
"https://shopee.co.id/search?keyword=iphone",
"https://shopee.co.id/Elektronik-cat.11044070"
]
}'
# Poll Status & collect download URLs
curl "https://nest-api.magpieiq.com/shopee/search-items/retrieve/{job_id}" \
-H "Authorization: Bearer YOUR_API_TOKEN"
# Download a specific result (download_url requires the same Bearer token)
curl "https://nest-api.magpieiq.com/shopee/pgnt/jobs/{job_id}/items/{item_token}/data" \
-H "Authorization: Bearer YOUR_API_TOKEN"
View Python Example
import requests
import time
API_HOST = "https://nest-api.magpieiq.com"
headers = {"Authorization": "Bearer YOUR_API_TOKEN", "Content-Type": "application/json"}
# Submit
payload = {"urls": ["https://shopee.co.id/search?keyword=iphone"]}
resp = requests.post(f"{API_HOST}/shopee/search-items/submit", json=payload, headers=headers)
job_id = resp.json()["job_id"]
# Poll until complete
while True:
result = requests.get(f"{API_HOST}/shopee/search-items/retrieve/{job_id}", headers=headers).json()
if result["status"] in ["COMPLETED", "PARTIAL_COMPLETE"]:
for item in result["items"]:
print(f"URL: {item['url']}, Status: {item['status']}, Download: {item.get('download_url')}")
break
time.sleep(30)
โก Behavior
- Cost: 6 credits per URL
- Approval: Required (24h timeout)
- Region: Automatically extracted from URL (e.g., shopee.co.id โ ID)
- Results: One JSON file per URL containing all items from the search/category
- Download: Each
download_urlpoints to/shopee/pgnt/jobs/{job_id}/items/{token}/dataand requires the same Bearer token. - Data source: Returns items from
search_items(all pages)
Result Example
Search Items JSON Click to expand
5. Merchant Items
Scrape all products from Shopee merchant/shop pages. Up to 50 URLs per request.
Supported regions: ID ยท SG ยท TH ยท PH ยท MY ยท VN ยท TW
๐ Endpoint
POST /shopee/merchant-items/submit
GET /shopee/merchant-items/retrieve/{job_id}
๐ฅ Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
urls | array | Yes | Array of Shopee shop/merchant URLs (max 50) |
๐ Supported URL Formats
- Shop ID:
https://shopee.co.id/shop/24843249
๐ป Code Examples
# Submit Job
curl -X POST "https://nest-api.magpieiq.com/shopee/merchant-items/submit" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"urls": [
"https://shopee.co.id/shop/24843249",
"https://shopee.co.id/shop/651735813"
]
}'
# Poll Status & collect download URLs
curl "https://nest-api.magpieiq.com/shopee/merchant-items/retrieve/{job_id}" \
-H "Authorization: Bearer YOUR_API_TOKEN"
# Download a specific result
curl "https://nest-api.magpieiq.com/shopee/pgnt/jobs/{job_id}/items/{item_token}/data" \
-H "Authorization: Bearer YOUR_API_TOKEN"
View Python Example
import requests
import time
API_HOST = "https://nest-api.magpieiq.com"
headers = {"Authorization": "Bearer YOUR_API_TOKEN", "Content-Type": "application/json"}
# Submit
payload = {"urls": ["https://shopee.co.id/shop/24843249"]}
resp = requests.post(f"{API_HOST}/shopee/merchant-items/submit", json=payload, headers=headers)
job_id = resp.json()["job_id"]
# Poll & download results
while True:
result = requests.get(f"{API_HOST}/shopee/merchant-items/retrieve/{job_id}", headers=headers).json()
if result["status"] in ["completed", "partial_complete"]:
for item in result["items"]:
if item["status"] == "SUCCESS" and item["download_url"]:
data = requests.get(f"{API_HOST}{item['download_url']}", headers=headers).json()
print(item["url"], data.keys())
break
time.sleep(30)
โก Behavior
- Cost: 6 credits per URL
- Approval: Required (24h timeout)
- Region: Automatically extracted from URL (e.g., shopee.co.id โ ID)
- Results: One JSON file per shop URL containing all products
- Download: Use the
download_urlfrom retrieve to call/shopee/pgnt/jobs/{job_id}/items/{token}/datawith your Bearer token. - Data sources: Returns items from both:
rcmd_items- Recommended/active itemssearch_items?filter_sold_out=1- Sold out items (if any)
Result Example
Merchant Items JSON Click to expand
6. Tokopedia PDP Beta
Scrape product detail from Tokopedia product pages. Single task per request. No Approval Required
Region: ID (Tokopedia Indonesia)
๐ Endpoint
POST /tokopedia/pdp/submit
GET /tokopedia/pdp/retrieve/{task_id}
๐ฅ Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
product_key | string | Yes | Tokopedia product key (slug or slug-id from the product URL) |
shop_domain | string | Yes | Tokopedia shop domain (subdomain part of the shop URL) |
๐ Finding product_key and shop_domain
From a Tokopedia product URL like:
https://www.tokopedia.com/novoidminds/no-void-minds-formlock-oversized-t-shirt-core-1729569390278181925
shop_domain=novoidminds(first path segment after domain)product_key=no-void-minds-formlock-oversized-t-shirt-core-1729569390278181925(second path segment)
๐ป Code Examples
# Submit Task
curl -X POST "https://nest-api.magpieiq.com/tokopedia/pdp/submit" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"product_key": "no-void-minds-formlock-oversized-t-shirt-core-1729569390278181925",
"shop_domain": "novoidminds"
}'
# Retrieve Result (poll until status is "completed")
curl "https://nest-api.magpieiq.com/tokopedia/pdp/retrieve/{task_id}" \
-H "Authorization: Bearer YOUR_API_TOKEN"
View Python Example
import requests
import time
API_HOST = "https://nest-api.magpieiq.com"
headers = {"Authorization": "Bearer YOUR_API_TOKEN", "Content-Type": "application/json"}
# Submit
resp = requests.post(f"{API_HOST}/tokopedia/pdp/submit",
json={
"product_key": "no-void-minds-formlock-oversized-t-shirt-core-1729569390278181925",
"shop_domain": "novoidminds"
}, headers=headers)
task_id = resp.json()["task_id"]
# Poll until ready
while True:
result = requests.get(f"{API_HOST}/tokopedia/pdp/retrieve/{task_id}", headers=headers).json()
if result.get("status") == "completed":
print(result["result"])
break
time.sleep(5)
โก Behavior
- Cost: 1 credit per request (beta pricing)
- Approval: NOT required - immediate processing
- Processing: Single task per request
- Results: Full product detail page data including variants, pricing, shop info, and brand
- Batch: For multiple products, submit each separately (batch endpoint coming soon)
Result Example
Tokopedia PDP JSON Click to expand
7. Blibli PDP Beta
Scrape product detail from Blibli product pages. Single task per request. No Approval Required
Region: ID (Blibli Indonesia)
๐ Endpoint
POST /blibli/pdp/submit
GET /blibli/pdp/retrieve/{task_id}
๐ฅ Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
formattedId | string | Yes | Blibli formatted product ID (e.g. ps--16M-70001-00016) |
sku | string | Yes | Blibli SKU (e.g. 16M-70001-00016-00001) |
pickupPointCode | string | No | Blibli pickup point code (e.g. PP-3491245) |
id | string | No | Product ID used as the GCS filename key; defaults to sku |
๐ Finding formattedId and sku
From a Blibli product URL like:
https://www.blibli.com/p/sample-product/ps--16M-70001-00016
formattedId=ps--16M-70001-00016(last path segment)sku=16M-70001-00016-00001(from product detail API or product variants)
๐ป Code Examples
# Submit Task
curl -X POST "https://nest-api.magpieiq.com/blibli/pdp/submit" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"formattedId": "ps--16M-70001-00016",
"sku": "16M-70001-00016-00001"
}'
# Retrieve Result (poll until status is "completed")
curl "https://nest-api.magpieiq.com/blibli/pdp/retrieve/{task_id}" \
-H "Authorization: Bearer YOUR_API_TOKEN"
View Python Example
import requests
import time
API_HOST = "https://nest-api.magpieiq.com"
headers = {"Authorization": "Bearer YOUR_API_TOKEN", "Content-Type": "application/json"}
# Submit
resp = requests.post(f"{API_HOST}/blibli/pdp/submit",
json={
"formattedId": "ps--16M-70001-00016",
"sku": "16M-70001-00016-00001"
}, headers=headers)
task_id = resp.json()["task_id"]
# Poll until ready
while True:
result = requests.get(f"{API_HOST}/blibli/pdp/retrieve/{task_id}", headers=headers).json()
if result.get("status") == "completed":
print(result["result"])
break
time.sleep(5)
โก Behavior
- Cost: 1 credit per request (beta pricing)
- Approval: NOT required - immediate processing
- Processing: Single task per request
- Results: Full product detail page data including variants, pricing, stock, and merchant info
- Batch: For multiple products, submit each separately
Result Example
Blibli PDP JSON Click to expand
๐ Job Status Reference
Job Statuses:
AWAITING_APPROVAL- Pending team approvalPROCESSING- Approved, scraping in progressCOMPLETED- All items successfulPARTIAL_COMPLETE- Some items failedFAILED- All items failedREJECTED- Rejected or timed out
HTTP Status Codes:
200- Success202- Job accepted401- Invalid/missing token402- Insufficient credits404- Job not found422- Validation error
For interactive API documentation, see Swagger UI.