# Tonghuashun (同花顺) Finance Scraper (`crawlerbros/tonghuashun-scraper`) Actor

Scrape Tonghuashun (10jqka.com.cn) A-share stock quotes via the public realhead API, market news via the news feed API, and stock search. Returns price, change, volume, turnover, 52-week high/low, P/E, news items with related stocks.

- **URL**: https://apify.com/crawlerbros/tonghuashun-scraper.md
- **Developed by:** [Crawler Bros](https://apify.com/crawlerbros) (community)
- **Categories:** Automation, News, Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Tonghuashun (同花顺) Finance Scraper

Scrapes [10jqka.com.cn](https://www.10jqka.com.cn) — one of China's largest
stock/finance platforms — for A-share quotes and market news.

### Data Source

Public JSON APIs (no login, no cookies):

- Quote: `d.10jqka.com.cn/v2/realhead/hs_{code}/last.js`
- News: `news.10jqka.com.cn/tapp/news/push/stock/`
- Name→code resolution: `smartbox.gtimg.cn` (public Tencent suggest service)

Both verified reachable without authentication.

### Modes

| Mode | Inputs | Source |
|---|---|---|
| `byStock` (default) | `stockCodes` | realhead quote API; codes accept `600519`, `sh600519`, `000001.SZ` forms |
| `marketNews` | `maxNewsItems` | paginated news feed with tags, timestamps, related stocks |
| `search` | `searchQuery` | code → direct quote; Chinese company name → resolved to codes via the public Tencent smartbox (`smartbox.gtimg.cn`), with 10jqka news-feed associations as fallback, then quotes fetched |
| `byStockUrl` | `stockUrls` | extracts the 6-digit code from any 10jqka URL and fetches its quote |

### Output fields

`stock` records: `stockCode`, `stockName`, `price`, `prevClose`, `open`, `high`,
`low`, `volume` (shares), `turnover` (CNY), `avgPrice`, `bid1Price`, `ask1Price`,
`change`, `changePct`, `high52w`, `low52w`, `peRatio` (TTM), `staticPERatio`,
`turnoverRate` (%), `volumeRatio`, `amplitude` (%), `totalShares`, `marketCap`,
`floatMarketCap`, `exchange` (sh/sz), `marketStatus`, `quoteTime`, `sourceUrl`.

All numeric fields are cross-validated against Tencent's realtime quote API
(qt.gtimg.cn); field IDs that fail validation are not shipped.

`news` records: `newsId`, `title`, `digest`, `url`, `tags`, `relatedStocks`
(`[{name, stockCode}]`), `publishedAt` (UTC ISO), `sourceUrl`.

Every record carries `recordType`, `sourceUrl` and `scrapedAt`.

### Filters

- `minChangePct` — drop stock records with `|changePct|` below the threshold
  (news records unaffected).

### Reliability

- Exponential-backoff retries on 429/5xx and the intermittent TLS resets this
  Chinese CDN produces.
- On 403/429 the actor lazily engages the free Apify `AUTO` datacenter proxy group.
- Invalid codes / unreachable quotes produce typed `recordType: "error"` records.
- Duplicate inputs are deduped: repeated codes resolve once (`600519` +
  `sh600519` → one quote), repeated invalid codes produce one error record.

### Limitations

- The numeric field IDs in the quote payload were cross-validated against
  Tencent's quotes; if 10jqka changes a field ID, that one field silently
  drops (omit-empty), others remain correct.
- Full-text company-name search resolves via the public Tencent smartbox
  (`smartbox.gtimg.cn`), because 10jqka's own search suggest API was retired
  (search.10jqka.com.cn now runs a captcha-gated AI gateway). If smartbox
  returns no match, the actor falls back to 10jqka's news-feed stock
  associations (up to 10 pages scanned) — a name only resolves via the
  fallback if it appears in the recent feed. Codes always resolve directly.
- News article and stock-page URLs (`url`, `stockpage.10jqka.com.cn/...`)
  return 403 to bare HTTP clients without a browser User-Agent; they load
  normally in a browser. The data URLs emitted on records (`sourceUrl`
  against `d.10jqka.com.cn`) answer 200 from any client.

# Actor input Schema

## `mode` (type: `string`):

What to fetch.

## `stockCodes` (type: `array`):

A-share codes, optionally with exchange prefix or suffix: `600519`, `sh600519`, `000001.SZ`, `300750`.

## `searchQuery` (type: `string`):

Stock code or company name. Codes resolve directly; names are resolved via the public Tencent smartbox (with 10jqka news-feed associations as fallback), then quotes are fetched.

## `stockUrls` (type: `array`):

e.g. `https://stockpage.10jqka.com.cn/600519/` or any 10jqka page containing a 6-digit A-share code.

## `maxNewsItems` (type: `integer`):

Number of news articles to fetch per page of the feed.

## `minChangePct` (type: `integer`):

Drop stock records whose absolute daily change % is below this threshold (applies to stock modes; news records unaffected).

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

Hard cap on emitted records.

## Actor input object example

```json
{
  "mode": "byStock",
  "stockCodes": [
    "600519"
  ],
  "searchQuery": "贵州茅台",
  "stockUrls": [],
  "maxNewsItems": 10,
  "maxItems": 20
}
```

# Actor output Schema

## `records` (type: `string`):

Dataset containing all scraped quotes and news items.

# 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 = {
    "mode": "byStock",
    "stockCodes": [
        "600519"
    ],
    "searchQuery": "贵州茅台",
    "stockUrls": [],
    "maxNewsItems": 10,
    "maxItems": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("crawlerbros/tonghuashun-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 = {
    "mode": "byStock",
    "stockCodes": ["600519"],
    "searchQuery": "贵州茅台",
    "stockUrls": [],
    "maxNewsItems": 10,
    "maxItems": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("crawlerbros/tonghuashun-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 '{
  "mode": "byStock",
  "stockCodes": [
    "600519"
  ],
  "searchQuery": "贵州茅台",
  "stockUrls": [],
  "maxNewsItems": 10,
  "maxItems": 20
}' |
apify call crawlerbros/tonghuashun-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,crawlerbros/tonghuashun-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/Em68zsGYsM6IgNSaM/builds/hIkxUruHZNLonLseU/openapi.json
