{
    "openapi": "3.0.0",
    "info": {
        "title": "全国行政区划 - API文档",
        "version": "1.0.0",
        "description": "全国五级行政区划查询，省、市、区（县）、街道（乡镇）、社区（村）联动查询。请注意，直辖市是省级行政区（如北京市），相对应的市级行政区分为市辖区或市辖县、相对应的区县级行政区如东城区或密云县。接口不带参数情况下，默认返回所有省级行政区，通过其中的省ID可继续查询对应的所有市级行政区，以此类推往向下查询。注：港澳台只有一级行政区信息。"
    },
    "servers": [
        {
            "url": "https:\/\/apis.tianapi.com"
        }
    ],
    "paths": {
        "\/area\/index": {
            "get": {
                "summary": "全国行政区划查询",
                "tags": [
                    "全国行政区划"
                ],
                "description": "支持城市区划ID五级行政区划联动查询",
                "parameters": [
                    {
                        "name": "key",
                        "in": "query",
                        "description": "API密钥",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "description": "API密钥"
                        }
                    },
                    {
                        "name": "city",
                        "in": "query",
                        "description": "市级行政区ID（市辖区\/市辖县），获取区县级行政区",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "example": "421100000000",
                            "description": "市级行政区ID（市辖区\/市辖县），获取区县级行政区"
                        }
                    },
                    {
                        "name": "town",
                        "in": "query",
                        "description": "乡镇（街道）级行政区ID，获取社区（村）级行政区",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "example": "421123100000",
                            "description": "乡镇（街道）级行政区ID，获取社区（村）级行政区"
                        }
                    },
                    {
                        "name": "county",
                        "in": "query",
                        "description": "区县级行政区ID，获取乡镇（街道）级行政区",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "example": "421123000000",
                            "description": "区县级行政区ID，获取乡镇（街道）级行政区"
                        }
                    },
                    {
                        "name": "village",
                        "in": "query",
                        "description": "社区（村）级行政区ID，获取全部上级行政区",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "example": "421123100212",
                            "description": "社区（村）级行政区ID，获取全部上级行政区"
                        }
                    },
                    {
                        "name": "province",
                        "in": "query",
                        "description": "省级行政区ID（含直辖市），获取市级行政区",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "example": "420000",
                            "description": "省级行政区ID（含直辖市），获取市级行政区"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功响应",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "id": {
                                            "type": "int",
                                            "example": 1,
                                            "description": "数据编号"
                                        },
                                        "cityid": {
                                            "type": "string",
                                            "example": "421100000000",
                                            "description": "市级行政区ID"
                                        },
                                        "townid": {
                                            "type": "string",
                                            "example": "421123100000",
                                            "description": "乡镇（街道）行政区ID"
                                        },
                                        "cityname": {
                                            "type": "string",
                                            "example": "黄冈市",
                                            "description": "市级行政区名称"
                                        },
                                        "countyid": {
                                            "type": "string",
                                            "example": "421123000000",
                                            "description": "区县级行政区ID"
                                        },
                                        "townname": {
                                            "type": "string",
                                            "example": "凤山镇",
                                            "description": "乡镇（街道）级行政区名称"
                                        },
                                        "villageid": {
                                            "type": "string",
                                            "example": "421123100212",
                                            "description": "社区（村）级行政区ID"
                                        },
                                        "countyname": {
                                            "type": "string",
                                            "example": "罗田县",
                                            "description": "区县级行政区名称"
                                        },
                                        "provinceid": {
                                            "type": "string",
                                            "example": "420000",
                                            "description": "省级行政区ID"
                                        },
                                        "villagename": {
                                            "type": "string",
                                            "example": "七里牌村",
                                            "description": "社区（村）级行政区名称"
                                        },
                                        "provincename": {
                                            "type": "string",
                                            "example": "湖北省",
                                            "description": "行政区名称"
                                        }
                                    }
                                },
                                "example": {
                                    "msg": "success",
                                    "code": 200,
                                    "result": {
                                        "list": [
                                            {
                                                "id": 1,
                                                "cityid": "110100000000",
                                                "townid": "110101001000",
                                                "cityname": "市辖区",
                                                "countyid": "110101000000",
                                                "townname": "东华门街道办事处",
                                                "villageid": "110101001001",
                                                "countyname": "东城区",
                                                "provinceid": "110000",
                                                "villagename": "多福巷社区",
                                                "provincename": "北京市"
                                            },
                                            {
                                                "id": 2,
                                                "cityid": "120100000000",
                                                "townid": "120101001000",
                                                "cityname": "市辖区",
                                                "countyid": "120101000000",
                                                "townname": "劝业场街道",
                                                "villageid": "120101001001",
                                                "countyname": "和平区",
                                                "provinceid": "120000",
                                                "villagename": "花园路社区",
                                                "provincename": "天津市"
                                            },
                                            {
                                                "id": 3,
                                                "cityid": "130100000000",
                                                "townid": "130102001000",
                                                "cityname": "石家庄市",
                                                "countyid": "130102000000",
                                                "townname": "建北街道办事处",
                                                "villageid": "130102001001",
                                                "countyname": "长安区",
                                                "provinceid": "130000",
                                                "villagename": "棉一社区",
                                                "provincename": "河北省"
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "summary": "全国行政区划查询",
                "tags": [
                    "全国行政区划"
                ],
                "description": "支持城市区划ID五级行政区划联动查询",
                "requestBody": {
                    "content": {
                        "application\/x-www-form-urlencoded": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "key": {
                                        "type": "string",
                                        "description": "API密钥"
                                    },
                                    "city": {
                                        "type": "string",
                                        "example": "421100000000",
                                        "description": "市级行政区ID（市辖区\/市辖县），获取区县级行政区"
                                    },
                                    "town": {
                                        "type": "string",
                                        "example": "421123100000",
                                        "description": "乡镇（街道）级行政区ID，获取社区（村）级行政区"
                                    },
                                    "county": {
                                        "type": "string",
                                        "example": "421123000000",
                                        "description": "区县级行政区ID，获取乡镇（街道）级行政区"
                                    },
                                    "village": {
                                        "type": "string",
                                        "example": "421123100212",
                                        "description": "社区（村）级行政区ID，获取全部上级行政区"
                                    },
                                    "province": {
                                        "type": "string",
                                        "example": "420000",
                                        "description": "省级行政区ID（含直辖市），获取市级行政区"
                                    }
                                },
                                "required": [
                                    "key"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "成功响应",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "id": {
                                            "type": "int",
                                            "example": 1,
                                            "description": "数据编号"
                                        },
                                        "cityid": {
                                            "type": "string",
                                            "example": "421100000000",
                                            "description": "市级行政区ID"
                                        },
                                        "townid": {
                                            "type": "string",
                                            "example": "421123100000",
                                            "description": "乡镇（街道）行政区ID"
                                        },
                                        "cityname": {
                                            "type": "string",
                                            "example": "黄冈市",
                                            "description": "市级行政区名称"
                                        },
                                        "countyid": {
                                            "type": "string",
                                            "example": "421123000000",
                                            "description": "区县级行政区ID"
                                        },
                                        "townname": {
                                            "type": "string",
                                            "example": "凤山镇",
                                            "description": "乡镇（街道）级行政区名称"
                                        },
                                        "villageid": {
                                            "type": "string",
                                            "example": "421123100212",
                                            "description": "社区（村）级行政区ID"
                                        },
                                        "countyname": {
                                            "type": "string",
                                            "example": "罗田县",
                                            "description": "区县级行政区名称"
                                        },
                                        "provinceid": {
                                            "type": "string",
                                            "example": "420000",
                                            "description": "省级行政区ID"
                                        },
                                        "villagename": {
                                            "type": "string",
                                            "example": "七里牌村",
                                            "description": "社区（村）级行政区名称"
                                        },
                                        "provincename": {
                                            "type": "string",
                                            "example": "湖北省",
                                            "description": "行政区名称"
                                        }
                                    }
                                },
                                "example": {
                                    "msg": "success",
                                    "code": 200,
                                    "result": {
                                        "list": [
                                            {
                                                "id": 1,
                                                "cityid": "110100000000",
                                                "townid": "110101001000",
                                                "cityname": "市辖区",
                                                "countyid": "110101000000",
                                                "townname": "东华门街道办事处",
                                                "villageid": "110101001001",
                                                "countyname": "东城区",
                                                "provinceid": "110000",
                                                "villagename": "多福巷社区",
                                                "provincename": "北京市"
                                            },
                                            {
                                                "id": 2,
                                                "cityid": "120100000000",
                                                "townid": "120101001000",
                                                "cityname": "市辖区",
                                                "countyid": "120101000000",
                                                "townname": "劝业场街道",
                                                "villageid": "120101001001",
                                                "countyname": "和平区",
                                                "provinceid": "120000",
                                                "villagename": "花园路社区",
                                                "provincename": "天津市"
                                            },
                                            {
                                                "id": 3,
                                                "cityid": "130100000000",
                                                "townid": "130102001000",
                                                "cityname": "石家庄市",
                                                "countyid": "130102000000",
                                                "townname": "建北街道办事处",
                                                "villageid": "130102001001",
                                                "countyname": "长安区",
                                                "provinceid": "130000",
                                                "villagename": "棉一社区",
                                                "provincename": "河北省"
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}