## Appendix: NBS Generic Interfaces
> Interfaces implemented in this chapter are listed below; uncovered indicators are noted under “To be added” at the end.
#### NBS national data
Interface: macro_china_nbs_nation
Source URL: https://data.stats.gov.cn/easyquery.htm
Description: Generic NBS national-data interface covering monthly, quarterly, and annual series; see the official data site for specific indicators.
Limits: Returns data according to the given parameters
Input
| Name | Type | Description |
|--------|-----|----------------------------------------------------------------------------------------------------------------------------------------------------|
| kind | str | Data category: monthly, quarterly, or annual. Pass the Chinese labels used by the API, e.g. `月度数据` (monthly), `季度数据` (quarterly), `年度数据` (annual). |
| path | str | Data path; must match `kind`. See the official site. Join hierarchy levels with ` > `.
Examples (Chinese API labels):
`国民经济核算 > 支出法国内生产总值` (GDP by expenditure)
`人口 > 总人口` (total population)
`金融业 > 保险系统机构、人员数 > 保险系统机构数` (insurance institutions) |
| period | str | Time range (comma-separated, no extra spaces):
Month: `201201,201205`
Quarter: `2012A,2012B,2012C,2012D`
Year: `2012,2013`
Through present: `2013-`
Recent: `last10` |
Output
| Name | Type | Description |
|----|----|----|
| - | - | - |
Example
```python
import meshare as ms
macro_china_nbs_nation_df = ms.macro_china_nbs_nation(kind="年度数据", path="人口 > 总人口", period="LAST5")
print(macro_china_nbs_nation_df)
```
Sample data
```
2022 2021 2020 2019 2018
Year-end total pop. (10k) 141175.0 141260.0 141212.0 141008.0000 140541.000000
Male pop. (10k) 72206.0 72311.0 72357.0 72039.0000 71863.871426
Female pop. (10k) 68969.0 68949.0 68855.0 68969.0000 68677.128574
Urban pop. (10k) 92071.0 91425.0 90220.0 88426.1168 86432.715000
Rural pop. (10k) 49104.0 49835.0 50992.0 52581.8832 54108.285000
```
#### NBS regional data
Interface: macro_china_nbs_region
Source URL: https://data.stats.gov.cn/easyquery.htm
Description: Generic NBS regional-data interface covering provincial monthly/quarterly/annual series, major-city monthly prices and annual data, and Hong Kong/Macao/Taiwan monthly and annual data; see the official data site for specific indicators.
Limits: Returns data according to the given parameters
Input
| Name | Type | Description |
|-----------|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| kind | str | Data category. Pass the Chinese labels used by the API, e.g. `分省月度数据` (provincial monthly), `分省季度数据` (provincial quarterly), `分省年度数据` (provincial annual), `主要城市月度价格` (major-city monthly prices), `主要城市年度数据` (major-city annual), `港澳台月度数据` (HK/Macao/Taiwan monthly), `港澳台年度数据` (HK/Macao/Taiwan annual). |
| path | str | Data path; must match `kind`. See the official site. Join hierarchy levels with ` > `.
Examples (Chinese API labels):
`国民经济核算 > 地区生产总值` (regional GDP)
`财政 > 地方财政收入` (local fiscal revenue) |
| indicator | Union[str, None] | Indicator under the current `path`. When `region` is set, this may be `None` to fetch all available indicators for that region. `indicator` and `region` cannot both be `None`. |
| region | Union[str, None] | Region filter; when set, returns data for that region only (Chinese region name as on the NBS site, e.g. `河北省`). |
| period | str | Time range (comma-separated, no extra spaces):
Month: `201201,201205`
Quarter: `2012A,2012B,2012C,2012D`
Year: `2012,2013`
Through present: `2013-`
Recent: `last10` |
Output
| Name | Type | Description |
|----|----|----|
| - | - | - |
Example
```python
import meshare as ms
macro_china_nbs_region_df = ms.macro_china_nbs_region(kind="分省季度数据", path="国民经济核算 > 地区生产总值", period="last3", indicator=None, region="河北省")
print(macro_china_nbs_region_df)
macro_china_nbs_region_df = ms.macro_china_nbs_region(kind="分省季度数据", path="人民生活 > 居民人均可支配收入", indicator='居民人均可支配收入_累计值(元)', period="2022")
print(macro_china_nbs_region_df)
```
Sample data
```
region_gdp_df
Hebei 2023 Q2 2023 Q1 2022 Q4
Regional GDP cumulative (100m yuan) 20779.0 10041.0 42370.0
Regional GDP index (same period last year=100) cum. (%) 106.1 105.1 103.8
region_income_df
Per capita disposable income cumulative (yuan) 2022 Q4 2022 Q3 2022 Q2 2022 Q1
Beijing 77414.548842 58596.590041 39391.260057 20630.0
Tianjin 48976.122565 38934.695987 25453.536929 14082.0
Hebei 30867.016699 22783.082852 14998.243977 7863.0
... ... ... ... ...
Xinjiang 27062.738782 16553.955250 10747.883634 5713.0
```