province-city-china
    TypeScript icon, indicating that this package has built-in type declarations

    8.0.0 • Public • Published

    中华人民共和国行政区划代码

    Github Issues Github Forks Github Stars Github Release npm package

    中华人民共和国行政区划(五级):省级、地级、县级、乡级和村级。来自中华人民共和国民政部,用于查询中国省,市和区数据的网站。

    数据更新时间:2020/11/24 20:24:52 GMT+0800 (中国标准时间)
    

    数据更新 Diff

    安装

    npm install province-city-china --save-dev
    包名 说明 版本 大小
    province-city-china 包含所有包内容 npm package -
    @province-city-china/country 国家和地区代码列表 npm package
    @province-city-china/data 总数据(省/地/县/乡) npm package
    @province-city-china/province 省级(省/直辖市/特别行政区) npm package
    @province-city-china/city 地级(城市) npm package
    @province-city-china/area 县级(区县) npm package
    @province-city-china/town 乡级(乡镇/街) npm package
    @province-city-china/level 总数据(省/地/县/乡)层级数据 npm package
    @province-city-china/utils 提供使用数据方法 npm package
    @province-city-china/types 类型文件 npm package -

    使用

    const { data, province, city, area, town } = require('province-city-china/data');
    • data - 总数据(省/地/县/乡)
    • province - 省级(省/直辖市/特别行政区)
    • city - 地级(城市)
    • area - 县级(区县)
    • town - 乡级(乡镇/街)

    所有数据

    const provinces = require('province-city-china/dist/data.json');
    // provinces 输出 ===>
    [
      {"code":"110000","name":"北京市","province":"11","city":0,"area":0,"town":0},
      {"code":"110101","name":"东城区","province":"11","city":"01","area":"01","town":0},
      {"code":"110102","name":"西城区","province":"11","city":"01","area":"02","town":0},
      {"code":"110105","name":"朝阳区","province":"11","city":"01","area":"05","town":0},
      ....
    ]

    规则:

    • province - 省级(省/直辖市/特别行政区) - city=0, area=0, town=0
    • city - 地级(城市) - area=0, town=0
    • area - 县级(区县) - town=0 其它不为 0
    • town - 乡级(乡镇/街) - 所有值不为 0

    province 第一位表示:华北区1,东北区2,华东区3,中南区4,西南区5,西北区6。 如 湖北省 -> 424 开头,表示为 中南区

    获取城市数据

    const city = require('province-city-china/dist/city.json');
    // city 输出 ===>
    [
      {"code":"01","name":"石家庄市","province":"13"},
      {"code":"02","name":"唐山市","province":"13"},
      {"code":"03","name":"秦皇岛市","province":"13"},
      {"code":"04","name":"邯郸市","province":"13"},
      {"code":"05","name":"邢台市","province":"13"},
      ....
    ]

    说明:

    • code - 城市代码
    • name - 城市名称
    • province - 省/直辖市/特别行政区代码

    更多数据

    可以通过 UNPKG 下载使用 CDN 资源: https://unpkg.com/province-city-china/dist/

    文件列表 JSON CSV SQL CDN
    国家和地区代码列表(#13) country.json (min) country.csv - csv / json
    总数据(省/地/县/乡) data.json (min) data.csv data.sql data.sql / csv / json
    总数据(省/地/县/乡)层级数据 level.json (min) - - level.json
    省级(省/直辖市/特别行政区) province.json (min) province.csv - province.json / csv
    地级(城市) city.json (min) city.csv - city.json / csv
    县级(区县) area.json (min) area.csv - area.json / csv
    乡级(乡镇/街) town.json (min) town.csv - town.json / csv
    县市区没有乡级数据 cityNotFoundTown.json (min) - - cityNotFoundTown.json

    更多 CDN 数据访问

    > <省市区>数据:3212
      ✔ 数据保存: dist/data.json
    > <>数据:34
      ✔ 数据保存: dist/province.json
      ✔ 数据保存: dist/province.csv
    > <>数据:333
      ✔ 数据保存: dist/city.json
      ✔ 数据保存: dist/city.csv
    > <>数据:2845
      ✔ 数据保存: dist/area.json
      ✔ 数据保存: dist/area.csv
    > 省市区:数据生成完成!

    国家和地区代码列表

    country.json | country.min.json | country.csv

    id=序号cnname=中文简称name=英文简称fullname=英文全称alpha2=两字母代码alpha3=三字母代码numeric=数字代码

    [
      {
        "id": 1,
        "cnname": "阿富汗",
        "name": "Afghanistan",
        "fullname": "the Islamic Republic of Afghanistan",
        "alpha2": "AF",
        "alpha3": "AFG",
        "town": 4
      },
      {
        "id": 45,
        "cnname": "中国",
        "name": "China",
        "fullname": "the People's Republic of China",
        "alpha2": "CN",
        "alpha3": "CHN",
        "town": 156
      }
      // ...
    ]

    压缩数据说明 country.min.json

    id: 'i'
    cnname: 'c'
    name: 'n'
    fullname: 'f'
    alpha2: 'a2'
    alpha3: 'a3'
    numeric: 'r'

    总数据(省/地/县/乡)

    data.json | data.min.json | data.csv | data.sql

    [
      {
        "code": "110000",
        "name": "北京市",
        "province": "11",
        "city": 0,
        "area": 0,
        "town": 0
      },
      // ...
    ]

    压缩数据说明 data.min.json

    code: 'c'
    name: 'n'
    province: 'p'
    city: 'y'
    area: 'a'
    town: 't'

    省/地/县/乡层级数据

    level.json | level.min.json

    [
      {
        "code": "420000",
        "name": "湖北省",
        "province": "42",
        "children": [
          {
            "code": "420100",
            "name": "武汉市",
            "province": "42",
            "city": "01",
            "children": [
              {
                "code": "420102",
                "name": "江岸区",
                "province": "42",
                "city": "01",
                "area": "02"
              },
              // ...
            ]
          }
          // ...
        ]
      }
      // ...
    ]

    压缩数据说明 level.min.json

    code: 'c'
    name: 'n'
    province: 'p'
    city: 'y'
    area: 'a'
    children: 'd'

    省级(省/直辖市/特别行政区)

    province.json | province.min.json | province.csv

    [
      {
        "code": "110000",
        "name": "北京市",
        "province": "11"
      },
      {
        "code": "120000",
        "name": "天津市",
        "province": "12"
      },
      // ...
    ]

    压缩数据说明 level.min.json

    code: 'c'
    name: 'n'
    province: 'p'
    city: 'y'
    area: 'a'
    children: 'd'

    地级(城市)

    city.json | city.min.json | city.csv

    [
      {
        "code": "130100",
        "name": "石家庄市",
        "province": "13",
        "city": "01"
      },
      // ...
    ]

    压缩数据说明 city.min.json

    code: 'c'
    name: 'n'
    province: 'p'
    city: 'y'

    县级(区县)

    area.json | area.min.json | area.csv

    [
      {
        "code": "110101",
        "name": "东城区",
        "province": "11",
        "city": "01",
        "area": "01"
      },
      // ...
    ]

    压缩数据说明 city.min.json

    code: 'c'
    name: 'n'
    province: 'p'
    city: 'y'
    area: 'a'

    乡级(乡镇/街)

    town.json | town.min.json | town.csv

    [
      {
        "code": "110101001000",
        "name": "东华门街道",
        "province": "11",
        "city": "01",
        "area": "01",
        "town": "001000"
      },
      // ...
    ]

    压缩数据说明 city.min.json

    code: 'c'
    name: 'n'
    province: 'p'
    city: 'y'
    area: 'a'
    town: 't'

    县市区没有乡级数据

    cityNotFoundTown.json | cityNotFoundTown.min.json

    [
      {
        "code": "659010",
        "name": "胡杨河市",
        "province": "65",
        "city": "90",
        "area": "10",
        "town": 0
      },
      // ...
    ]

    压缩数据说明 cityNotFoundTown.min.json

    code: 'c'
    name: 'n'
    province: 'p'
    city: 'y'
    area: 'a'
    town: 't'

    参考链接

    License

    MIT

    Install

    npm i province-city-china

    DownloadsWeekly Downloads

    505

    Version

    8.0.0

    License

    MIT

    Unpacked Size

    26.4 MB

    Total Files

    28

    Last publish

    Collaborators

    • avatar