中国行政区划代码
根据国家标准《中华人民共和国行政区划代码》即 GB2260 标准制定,用以查看各个省地县的行政区划代码,并支持多级联动查询
- 丰富的 API,满足多种级联查询
- 较小的 npm 包体积
版本
版本最近更新于 20210812,爬取数据为 http://www.mca.gov.cn/article/sj/xzqh/2020/20201201.html
安装
npm
$ npm install china-region
import { getProvinces } from 'china-region'
import province from 'china-region/region.json'
import province from 'china-region/province.json'
CDN
你可以在 CDN 中直接使用它,并调用 API。
<script src="https://cdn.jsdelivr.net/npm/china-region"></script>
<script>
const provinces = cn.getProvinces()
</script>
在线调试
你可以在 china-region 中,打开控制台,在线尝试该 API。
API
const cn = require('china-region')
const code = cn.getCodeByProvinceName('晋')
const cities = cn.getPrefectures(code)
cn.getCodeByProvinceName(name)
根据升级行政区名称或简称获取行政区划代码
cn.getCodeByProvinceName('山西省')
cn.getCodeByProvinceName('山西')
cn.getCodeByProvinceName('晋')
cn.info(code)
返回某个行政区号代表的行政区
cn.info('141024')
cn.info('140000')
cn.getAllRegions()
返回中国所有的各级行政区
cn.getAllRegions()
cn.getProvinces()
返回中国所有的省级行政区
cn.getProvinces()
cn.getProvinces().map(x => x.alias)
cn.getPrefectures(code)
返回中国/某省级行政区下所有的地级行政区
code 指行政区代码,code 为空时返回中国所有的地级行政区,不为空时返回该省级行政区的所有地级行政区
cn.getPrefectures()
cn.getPrefectures('100000')
cn.getPrefectures('101000')
cn.getPrefectures('101010')
cn.getCounties(code)
返回中国/某省级行政区/某地级行政区下所有的县级行政区
code 指行政区代码,code 为空时返回中国所有的县级行政区,不为空时返回该省/市级行政区的所有地级行政区
cn.getCounties()
cn.getCounties('100000')
cn.getCounties('101000')
cn.getSpecialConties(code)
返回中国/某省级行政区下所有的省直管县。如海南省的各县和县级市、湖北省的仙桃市、潜江市、天门市、神农架林区、河南省的济源市、新疆的数个由自治区和新疆兵团双重领导的县级市等
code 指行政区代码,code 为空时返回中国所有的县级行政区,不为空时返回该省/市级行政区的所有地级行政区
cn.getSpecialCounties()
cn.getSpecialCounties('100000')
术语
关于行政区级别翻译参考知乎两篇关于地名翻译的文章
province
,省级行政区,包括直辖市、省、自治区、特别行政区。prefecture
,地级行政区,包括地级市、地区、自治州、盟。county
,县级行政区,包括市辖区、县级市、县、自治县、旗、自治旗、特区、林区。specialCounty
,省直管县级行政区,如湖北的仙桃、潜江与天门
数据获取
行政代码在国家标准《中华人民共和国行政区划代码》即 GB2260 的标准下制定,可以在民政部统计数据中查询。
相关仓库