# CPI

- 接口：consumer_price_index_monthly
- 路径：/api/v1/market/data/economic/china-cpi
- 方法：GET
- 描述：查询中国居民消费价格指数（CPI）月度数据。按月份返回全国（含累计同比）、城市、农村三档 CPI 同比、环比和当月值；业务数据在 `data.items` 中按月份倒序分页返回。
- 数据范围：宏观经济月度数据
- 单次限量：默认 `page=1`、`page_size=200`；`page_size` 不设上限，超过总记录数时返回全部
- 提示：
  - 月份字段 `month` 已格式化为中文「YYYY年MM月份」。
  - 数值字段单位为百分比（%），部分月份字段缺失时为 null。

## 输入参数

| 名称 | 类型 | 必选 | 描述 |
|------|------|------|------|
| page | integer | N | 页码，从 1 开始，默认 1 |
| page_size | integer | N | 每页条数，默认 200 |


## 输出参数
成功响应外层固定为 `code`、`message`、`data`：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| code | integer | Y | 响应状态码；成功固定为 200 |
| message | string | Y | 成功固定为 `success`；失败时为中文错误信息 |
| data | object / null | Y | 成功时为分页对象；失败时为 `null` |

data 对象：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| items | array | Y | 当前页的 CPI 月度记录列表 |
| total_items | integer | Y | 总记录数 |
| total_pages | integer | Y | 总页数 |

items 数组：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| month | string | Y | 月份，格式「YYYY年MM月份」 |
| national_cpi | string | Y | 全国 CPI 当月值（%） |
| national_yoy | string | Y | 全国 CPI 同比（%） |
| national_mom | string / null | Y | 全国 CPI 环比（%）；无数据时为 `null` |
| cumulative | string / null | Y | 全国 CPI 累计同比（%）；无数据时为 `null` |
| city_cpi | string | Y | 城市 CPI 当月值（%） |
| city_yoy | string | Y | 城市 CPI 同比（%） |
| city_mom | string / null | Y | 城市 CPI 环比（%）；无数据时为 `null` |
| rural_cpi | string | Y | 农村 CPI 当月值（%） |
| rural_yoy | string | Y | 农村 CPI 同比（%） |
| rural_mom | string / null | Y | 农村 CPI 环比（%）；无数据时为 `null` |

## 接口示例

```bash
curl -sS "https://market.ft.tech/gateway/api/v1/market/data/economic/china-cpi?page=1&page_size=50"
```

Python（[`ftshare`](https://github.com/FTShare-Lab/FTShare-python-sdk.git) SDK，方法 `market.consumer_price_index_monthly`，默认返回 pandas `DataFrame`）：

```python
import ftshare as ft

market = ft.market_api()

# 返回第一页 DataFrame（按时间倒序）
df = market.consumer_price_index_monthly(page=1, page_size=50)
print(df.shape, list(df.columns)[:6])
# (50, 11) ['month', 'national_cpi', 'national_yoy', 'national_mom', 'cumulative', 'city_cpi']

# 只看最近几期
print(market.consumer_price_index_monthly(page=1, page_size=50).head(3))

# 返回原始 JSON（未经 DataFrame 抽取）
payload = market.consumer_price_index_monthly(raw=True)
```


## 数据样例

全量月度序列按月份降序返回，节选最新 5 期：

| month | national_cpi | national_yoy | national_mom | cumulative | city_cpi | city_yoy | city_mom | rural_cpi | rural_yoy | rural_mom |
|-------|--------------|--------------|--------------|------------|----------|----------|----------|-----------|-----------|-----------|
| 2026年08月份 | 100.8000 | 0.7937 | 0.3984 | 100.9000 | 100.8000 | 0.7937 | 0.3984 | 100.7000 | 0.6951 | 0.3984 |
| 2026年07月份 | 100.5000 | 0.4975 | -0.1001 | 100.9000 | 100.5000 | 0.4975 | -0.1001 | 100.4000 | 0.3984 | -0.2004 |
| 2026年06月份 | 101.0000 | 0.9901 | -0.3009 | 101.0000 | 101.0000 | 0.9901 | -0.4016 | 100.8000 | 0.7937 | -0.3009 |
| 2026年05月份 | 101.2000 | 1.1858 | -0.1001 | 101.0000 | 101.3000 | 1.2833 | -0.1001 | 101.1000 | 1.0880 | -0.1001 |
| 2026年04月份 | 101.2000 | 1.1858 | 0.2991 | 100.9000 | 101.2000 | 1.1858 | 0.2991 | 101.0000 | 0.9901 | 0.0999 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
