# CN 1688 Scraper (`codingfrontend/cn-1688-scraper`) Actor

Extract publicly visible 1688.com product cards, prices, suppliers, and demand signals.

- **URL**: https://apify.com/codingfrontend/cn-1688-scraper.md
- **Developed by:** [Coding Frontned](https://apify.com/codingfrontend) (community)
- **Features:** Limited permissions
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.99 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## CN 1688 Scraper

Extracts bounded, source-backed product listing evidence from public 1688.com search pages. A normal row is emitted only when a public 1688 product URL and usable title are visible in the permitted response; normal dataset rows contain public business/source fields only.

### What it collects

When 1688 exposes the values, rows include product ID, title, product and image URLs, visible price and price range, currency, minimum order quantity, supplier name and location, sales volume, public specifications, source-page provenance, page number, and a UTC emission timestamp. Missing optional values remain absent; the Actor does not infer private supplier information or commercial facts. Operational instrumentation, transport metadata, counters, and validation wrappers stay in the run summary/KVS artifacts.

### Source and access policy

- Live transport uses direct HTTPS requests to public `s.1688.com` search pages, with public 1688/detail and CDN URLs accepted only as extracted product/image evidence.
- Official requests are preceded by `s.1688.com/robots.txt` preflight and disallowed pages are skipped.
- Redirects, retries, request delay, timeout, response size, page count, and product count are bounded.
- CAPTCHA/security challenges, access-control responses, HTTP failures, empty responses, invalid URLs, and robot restrictions become separate minimal `recordType: "diagnostic"` rows. No login, cookies, private API, proxy rotation, browser automation, CAPTCHA solution, or access-control bypass is used.

### Input

Use `keywords` to generate public 1688 search URLs, or provide `searchUrls` as `{ "url": "..." }` objects. Explicit URLs take precedence; invalid explicit URLs are reported and never replaced with generated keyword requests. `maxPages` follows only observed next-page links, and `maxItems` is the global product cap.

| Field | Default | Limits and behavior |
| --- | --- | --- |
| `keywords` | `wireless earbuds` | Up to 20 search phrases |
| `searchUrls` | none | Public `s.1688.com/selloffer/offer_search.htm` URLs; up to 20 schema inputs |
| `maxPages` | `1` | Integer from 1 to 10 per source; observed pagination only |
| `startPage` | `1` | Integer from 1 to 1,000 for generated keyword searches |
| `maxItems` | `100` | Integer from 1 to 2,000 unique product rows |
| `maxRetries` | `2` | Integer from 1 to 5 attempts for retryable failures |
| `requestDelayMs` | `300` | Integer from 0 to 5,000 milliseconds between live requests |
| `requestTimeoutMs` | `30000` | Integer from 5,000 to 120,000 milliseconds |
| `maxBytes` | `5000000` | Integer from 1,000 to 15,000,000 response bytes |
| `includeDiagnostics` | `true` | Whether diagnostic rows are emitted to the dataset; summary evidence remains available |
| `sourceMode` | `live` | `live` or `fixture`; fixture mode never falls back to live |
| `fixtureHtml` | empty | Local QA HTML body |
| `fixtureFile` / `fixtureFiles` | none | Local HTML paths inside the Actor directory; one file can be reused or files can match source order |

Example:

```json
{
  "keywords": ["wireless earbuds", "usb hub"],
  "maxPages": 2,
  "maxItems": 100,
  "requestDelayMs": 500,
  "includeDiagnostics": true
}
```

Example explicit source:

```json
{
  "keywords": ["wireless earbuds"],
  "searchUrls": [
    { "url": "https://s.1688.com/selloffer/offer_search.htm?keywords=wireless%20earbuds" }
  ],
  "maxPages": 1,
  "maxItems": 50
}
```

For deterministic local QA:

```json
{
  "keywords": ["usb hub"],
  "sourceMode": "fixture",
  "fixtureFile": "test/fixtures/second-pass-products.html",
  "maxPages": 1,
  "maxItems": 5,
  "requestDelayMs": 0
}
```

### Output

The dataset contains:

- public product rows with source identity, public title/URL, page/search provenance, public commercial/supplier fields, and a UTC emission timestamp.
- minimal `diagnostic` rows with only `recordType`, public `url`, `error`, `errorCode`, and `scrapedAt`.

The reconciled run summary is written under `OUTPUT_SUMMARY`, `RUN_SUMMARY`, `OUTPUT`, and `SUMMARY`. `SOURCE_METADATA` records the public source boundary and privacy policy; `DIAGNOSTICS` records diagnostic evidence. Summary counts distinguish live requests, logical pages, products seen/stored, filtered or duplicate products, and diagnostics.

You can download the dataset in various formats such as JSON, HTML, CSV, or Excel.

### Local development

```text
npm ci
npm test
npm run lint
npm run validate
apify validate-schema
apify run --purge --input-file input.json
```

The public 1688 route may return a security challenge or robots restriction to a direct local request. In that case the Actor records a truthful blocked diagnostic and does not fabricate product data. This Actor is intended for local verification in this repository and does not use Apify login, push, call, cloud execution, or credentialed requests.

### Notes

Only public values visible in the permitted response are emitted. Respect 1688's terms, robots guidance, and applicable law; verify important sourcing decisions independently because prices, stock, sales signals, and suppliers can change.

# Actor input Schema

## `searchUrls` (type: `array`):

Public 1688.com search pages. Invalid explicit URLs are reported and never replaced with generated queries.

## `keywords` (type: `array`):

Keywords used to build a public 1688 search URL when searchUrls is not supplied.

## `maxPages` (type: `integer`):

Maximum result pages per supplied URL; only observed next-page links are followed.

## `startPage` (type: `integer`):

One-indexed page used for generated keyword searches.

## `maxItems` (type: `integer`):

Maximum unique product records to emit across all sources and pages.

## `maxRetries` (type: `integer`):

Attempts for retryable public request failures.

## `requestTimeoutMs` (type: `integer`):

Maximum wait for one public request.

## `maxBytes` (type: `integer`):

Safety limit for one public response.

## `includeDiagnostics` (type: `boolean`):

Whether explicit access and validation diagnostics are emitted to the dataset; summary evidence remains available.

## `requestDelayMs` (type: `integer`):

Delay between public page requests.

## `fixtureHtml` (type: `string`):

Optional HTML fixture for deterministic local validation.

## `sourceMode` (type: `string`):

Use live for public 1688 requests or fixture for deterministic local validation. Fixture mode never falls back to live.

## `fixtureFile` (type: `string`):

Local HTML fixture path inside the Actor directory.

## `fixtureFiles` (type: `array`):

One local HTML fixture per source URL, or one fixture reused for all URLs.

## Actor input object example

```json
{
  "searchUrls": [],
  "keywords": [
    "wireless earbuds"
  ],
  "maxPages": 1,
  "startPage": 1,
  "maxItems": 100,
  "maxRetries": 2,
  "requestTimeoutMs": 30000,
  "maxBytes": 5000000,
  "includeDiagnostics": true,
  "requestDelayMs": 300,
  "fixtureHtml": "",
  "sourceMode": "live"
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `runSummary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("codingfrontend/cn-1688-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("codingfrontend/cn-1688-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call codingfrontend/cn-1688-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,codingfrontend/cn-1688-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/cMzpOhfZp6bLwnCFk/builds/OW9fWwkTehoIQgaBl/openapi.json
