# Stats — Wrapped API

> **You are on:** `https://api.beta.paywithlocus.com/api` | [llms.txt](https://beta.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 for Locus Pro. Each call burns credits from your workspace balance.

## Access

**Base URL:** `https://api.beta.paywithlocus.com/api/wrapped/credits/stats/`
**Auth:** `Authorization: Bearer <LOCUS_CREDITS_SECRET_KEY>` (an `lcr_` secret key or a scoped `lcac_` agent credential)
**Required header:** `Idempotency-Key: <fresh UUID per call>`. A retry with the same key replays the stored result without a new charge.
**Response:** the provider response after any endpoint-specific normalization. `X-Locus-Credits-Charged` carries the charge and `X-Locus-Credits-Balance` the remaining balance. Insufficient credits return `402` before the provider is called.
**Pricing:** estimated costs below are USD. Locus debits the credit equivalent at your workspace rate.

Full call contract: https://docs.paywithlocus.com/api-reference/introduction

> Using a Pay With Locus wallet key (`claw_` prefix)? Wallet routes are documented separately: https://docs.paywithlocus.com/wrapped-apis/for-agents

## 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.beta.paywithlocus.com/api/wrapped/credits/stats/get-indicator-tree \
  -H "Authorization: Bearer $LOCUS_CREDITS_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -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.beta.paywithlocus.com/api/wrapped/credits/stats/get-money-supply \
  -H "Authorization: Bearer $LOCUS_CREDITS_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -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.beta.paywithlocus.com/api/wrapped/credits/stats/get-provincial-data \
  -H "Authorization: Bearer $LOCUS_CREDITS_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -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.beta.paywithlocus.com/api/wrapped/credits/stats/get-regions \
  -H "Authorization: Bearer $LOCUS_CREDITS_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -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.beta.paywithlocus.com/api/wrapped/credits/stats/get-time-periods \
  -H "Authorization: Bearer $LOCUS_CREDITS_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -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.beta.paywithlocus.com/api/wrapped/credits/stats/query-data \
  -H "Authorization: Bearer $LOCUS_CREDITS_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -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.beta.paywithlocus.com/api/wrapped/credits/stats/search-indicators \
  -H "Authorization: Bearer $LOCUS_CREDITS_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"page":"<integer>","query":"<string>"}'
```

## Next steps

- [All wrapped API providers](https://beta.paywithlocus.com/wapi/index.md): pick another provider.
- [Find and call tools](https://beta.paywithlocus.com/agent/tools.md): price ceilings, async results, and errors.
- [Credits and billing](https://beta.paywithlocus.com/agent/billing.md): what a call costs and how to add credits.
- [Agent docs index](https://beta.paywithlocus.com/agent/index.md): every Locus agent page.