# Tianyancha Company Search (`spider_studio/tianyancha-search`) Actor

Searches Tianyancha (天眼查) for companies by keyword and returns up to 20 matching companies per keyword.

- **URL**: https://apify.com/spider\_studio/tianyancha-search.md
- **Developed by:** [NewLai](https://apify.com/spider_studio) (community)
- **Categories:** Automation, E-commerce, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$3.00 / 1,000 search results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#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

### What does **tianyancha-search** do? | 天眼查企业查询与公司搜索

**tianyancha-search** is a **Tianyancha company search scraper and China business database API**. Give it one or more company names or keywords and it searches [Tianyancha (天眼查)](https://www.tianyancha.com/), returning up to 20 matching Chinese company records per query as structured JSON.

**中文简介：** 这是一个支持批量关键词的**天眼查企业查询、公司搜索和工商查询 API**，返回企业名称、法定代表人、注册资本、经营状态、统一社会信用代码、注册地址和天眼查 `gid`，适用于获客、KYC、企业尽调和中国企业数据库建设。

Each result is tagged with its source keyword. Use it alone or pass returned `gid` values to `tianyancha-basic-info` for full profiles, with automation available through the Apify API, schedules, webhooks, monitoring, and integrations.

### Why use **tianyancha-search**?

- **No browser, no manual login** — the encrypted request header is generated in pure Python, so runs are fast and cheap.
- **Clean structured JSON** — every company is flattened into its own dataset row, downloadable as JSON, CSV, Excel, XML, or HTML.
- **Batch by keyword** — search many keywords in a single run; each result is stored in the same dataset.
- **Ready for automation** — combine it with Apify **scheduling**, **webhooks**, and **API access** to power lead-gen, due-diligence, and KYC pipelines.
- **Apify platform advantages** — monitored runs, pay-per-use billing, proxy support, and 15 integrations out of the box.

### How to use **tianyancha-search**

1. Open the Actor's **Input** tab in the Apify Console.
2. Enter one or more search keywords (e.g. `["张雪机车", "腾讯"]`).
3. Optionally set **Results per keyword** (max `20`).
4. Click **Start**. The Actor searches each keyword and stores every company in the run's dataset.
5. Open the run's **Dataset** tab to preview the JSON, or download it in your preferred format.

You can also run it from the command line with the Apify CLI:

```bash
apify call <username>/tianyancha-search --input '{"words": ["张雪机车", "腾讯"]}'
```

### Input

The Actor takes the following input fields:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `words` | array\<string> | Yes | Search keywords, e.g. `["张雪机车", "腾讯"]` |
| `pageSize` | integer | No | Maximum companies per keyword (1–20, default `20`). The API does not support paging. |

Example input:

```json
{
  "words": ["张雪机车", "腾讯"],
  "pageSize": 20
}
```

All Tianyancha API requests use **Apify Residential Proxy** with the exit
location fixed to mainland China (`CN`). No custom proxy URL or proxy environment
variable is required. The Actor fails instead of falling back to a direct request.

The remaining runtime option is preset in the Actor configuration:

| Variable | Description |
|----------|-------------|
| `TYC_CONCURRENCY` | Maximum number of keywords searched concurrently. Preset and fallback: `8`. |

### Output

The Actor pushes one record per company to the default dataset. A representative (abbreviated) output item looks like:

```json
{
  "searchWord": "张雪机车",
  "id": 7066473513,
  "name": "重庆张雪摩托车销售有限公司",
  "legalPersonName": "张雪",
  "regStatus": "存续",
  "regCapital": "100万人民币",
  "estiblishTime": "2024-08-02 00:00:00.0",
  "creditCode": "91500112MADTJJ4X88",
  "categoryStr": "批发业",
  "regLocation": "重庆市渝北区空港大道1008号4幢2-4",
  "companyTotal": 61
}
```

The full payload mirrors the Tianyancha mobile search API and may contain many more fields per company. Highlight `<em>` tags are stripped for clean output. You can download the dataset in various formats such as JSON, HTML, CSV, or Excel.

### Data table

Main fields you can expect in the output:

| Field | Description |
|-------|-------------|
| `searchWord` | The keyword that produced this result |
| `id` | Tianyancha company ID (gid) — feed into `tianyancha-basic-info` for full details |
| `name` | Registered company name |
| `legalPersonName` | Legal representative |
| `regStatus` | Company status (e.g. 存续, 注销) |
| `regCapital` | Registered capital |
| `estiblishTime` | Establishment date |
| `creditCode` | Unified social credit code |
| `categoryStr` | Industry category |
| `regLocation` | Registered address |
| `companyTotal` | Total companies matching the keyword |

### How much does it cost to scrape Tianyancha?

Apify usage is measured in **compute units (CUs)**. Each run is a lightweight set of HTTP requests with no browser, so it consumes well under a fraction of a CU per keyword. With Apify's free tier, occasional searches cost nothing. For bulk searches, the default memory (256 MB) and short run duration keep costs minimal — you can estimate your exact spend on the Apify **Pricing** page.

### Tips or Advanced options

- **Batch keywords** — pass many `words` in a single run; every company lands in the same dataset. Feed a long list, or schedule repeated runs via the Apify API.
- **Feed the `tianyancha-basic-info` Actor** — search returns company `id`s; pipe them into the base-info Actor to pull each company's full registered profile.
- **Limit results** — set `pageSize` lower to reduce requests and speed up runs (the API caps at 20 anyway).
- **Fast and cheap** — the Actor uses plain HTTP, so it is far cheaper and faster than browser-based scrapers for the same data.

### FAQ, disclaimers, and support

- **Is this legal?** The Actor accesses Tianyancha's public mobile API. You are responsible for complying with Tianyancha's Terms of Service and applicable laws, and for how you use the data.
- **Known limitations** — the search API returns at most 20 results per keyword and does not support paging. The private API may change without notice; if the Authorization cipher changes, runs may fail until the Actor is updated.
- **Need a custom solution?** For tailored scraping, bulk export, or integration work, open an issue on the **Issues** tab or reach out for a custom Actor.

This page was generated with [Apify's Actor README guidelines](https://docs.apify.com/platform/actors/development/actor-guides/actor-readme).

# Actor input Schema

## `words` (type: `array`):

One or more keywords to search for, e.g. \["张雪机车", "腾讯"]. Each keyword returns up to pageSize company results.

## `pageSize` (type: `integer`):

Maximum number of company results to return per keyword. The Tianyancha search API caps this at 20 and does not support paging.

## Actor input object example

```json
{
  "words": [
    "腾讯"
  ],
  "pageSize": 20
}
```

# Actor output Schema

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

Dataset containing the matching companies for each requested keyword.

# 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 = {
    "words": [
        "腾讯"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("spider_studio/tianyancha-search").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 = { "words": ["腾讯"] }

# Run the Actor and wait for it to finish
run = client.actor("spider_studio/tianyancha-search").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 '{
  "words": [
    "腾讯"
  ]
}' |
apify call spider_studio/tianyancha-search --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,spider_studio/tianyancha-search"
        }
    }
}

```

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/BufesENCrWv49LKeU/builds/yuHNcrbKg5z6mEdlc/openapi.json
