# Stats — Wrapped API

> **You are on:** `https://api.paywithlocus.com/api` | [llms.txt](https://paywithlocus.com/llms.txt) | [docs](https://docs.paywithlocus.com)
>
> Locus runs on multiple environments -- make sure every URL you call matches your expected environment.
> | Environment | Landing | API | Docs |
> |---|---|---|---|
> | Production | paywithlocus.com | api.paywithlocus.com | docs.paywithlocus.com |
> | Beta | beta.paywithlocus.com | api.beta.paywithlocus.com | docs.paywithlocus.com |
> | Stage | stage.paywithlocus.com | api.stage.paywithlocus.com | docs.paywithlocus.com |
>
> If the API URL above doesn't match your expected environment, re-fetch this file from the correct domain.

> Access comprehensive statistical data, economic indicators, and official reports from China's National Bureau of Statistics through simple searches and structured queries. Retrieve detailed articles, data releases, indicator trends, and downloadable documents to analyze China's economic and social statistics.

**Category:** Government & Public Data | **Website:** [data.stats.gov.cn/](https://data.stats.gov.cn/) | **Docs:** [parse.bot/marketplace/a9c4019c-f767-4c31-b8a6-e9bbb3067314/data-stats-gov-cn-api](https://parse.bot/marketplace/a9c4019c-f767-4c31-b8a6-e9bbb3067314/data-stats-gov-cn-api)

Pay-per-use API proxy. Each call is automatically billed to your wallet in USDC.

## Access

**Base URL:** `https://api.paywithlocus.com/api/wrapped/parse-data-stats-gov-cn-api-a9c4019c/`
**Auth:** `Authorization: Bearer <LOCUS_API_KEY>`

## Endpoints

### get_indicator_tree

Browse the hierarchical tree of indicators, regions, or time periods. Use this to discover IDs for querying data.

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `dbcode` | string | Yes | Database code (e.g., 'hgyd' for national monthly, 'fsnd' for provincial annual) |
| `parent_id` | string | No | Parent ID to drill down into (empty for root) |
| `wdcode` | string | No | Dimension code: 'zb' (indicators), 'reg' (regions), 'sj' (time) |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/parse-data-stats-gov-cn-api-a9c4019c/get_indicator_tree \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"dbcode":"<string>","parent_id":"<string>","wdcode":"<string>"}'
```

### get_money_supply

Retrieve recent monthly money supply data (M0, M1, M2) from the NBS national monthly database.

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `limit` | integer | No | Number of recent months to retrieve |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/parse-data-stats-gov-cn-api-a9c4019c/get_money_supply \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"limit":"<integer>"}'
```

### get_provincial_data

Retrieve annual data for all 31 Chinese provinces for a specific indicator, structured by region and year.

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `indicator_code` | string | Yes | Indicator code (e.g., 'A020101' for Regional GDP) |
| `limit` | integer | No | Number of recent years to retrieve |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/parse-data-stats-gov-cn-api-a9c4019c/get_provincial_data \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"indicator_code":"<string>","limit":"<integer>"}'
```

### get_regions

Get list of region codes (provinces, cities) for a database.

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `dbcode` | string | Yes | Database code |
| `parent_id` | string | No | Parent region ID |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/parse-data-stats-gov-cn-api-a9c4019c/get_regions \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"dbcode":"<string>","parent_id":"<string>"}'
```

### get_time_periods

Get available time period codes for a database.

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `dbcode` | string | Yes | Database code |
| `parent_id` | string | No | Parent time ID |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/parse-data-stats-gov-cn-api-a9c4019c/get_time_periods \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"dbcode":"<string>","parent_id":"<string>"}'
```

### query_data

Execute a custom data query against the NBS database.

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `colcode` | string | No | Dimension for columns (usually 'sj' for time) |
| `dbcode` | string | Yes | Database code (e.g., 'hgyd', 'fsnd') |
| `dfwds` | string | No | Display filters as JSON list of dicts (e.g., '[{"wdcode":"sj","valuecode":"LAST10"}]') |
| `rowcode` | string | No | Dimension for rows (e.g., 'zb' for indicators, 'reg' for regions) |
| `wds` | string | No | Fixed dimension filters as JSON list of dicts (e.g., '[{"wdcode":"zb","valuecode":"A0101"}]') |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/parse-data-stats-gov-cn-api-a9c4019c/query_data \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"colcode":"<string>","dbcode":"<string>","dfwds":"<string>","rowcode":"<string>","wds":"<string>"}'
```

### search_indicators

Search for statistical indicators by keyword.

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `page` | integer | No | Page number |
| `query` | string | Yes | Keyword to search (Chinese or English) |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/parse-data-stats-gov-cn-api-a9c4019c/search_indicators \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"page":"<integer>","query":"<string>"}'
```
