

登录用户中心
城市搜索
天气数据是基于地理位置的数据,因此获取天气之前需要先知道具体的位置信息。使用城市搜索,可获取到该城市的基本信息,包括城市的Location ID(你需要这个ID去查询天气),多语言名称、经纬度、时区、海拔、Rank值、归属上级行政区域、所在行政区域等
更新时间:2026-02-01 11:44:13
请求方式:get
请求类型:none
秘钥KEY传参
| 参数名 | 参数类型 | 参数示例 | 参数说明 |
|---|---|---|---|
| ckey | string | SJKHJDBBDGGE | 支持通过:headers/query/body(x-www) |
Query参数
| 参数名 | 参数类型 | 参数示例 | 参数说明 |
|---|---|---|---|
| location | string | 北京 |
接口返回示例
{
"code": "200",
"location": [
{
"name": "北京",
"id": "101010100",
"lat": "39.90499",
"lon": "116.40529",
"adm2": "北京",
"adm1": "北京市",
"country": "中国",
"tz": "Asia/Shanghai",
"utcOffset": "+08:00",
"isDst": "0",
"type": "city",
"rank": "10",
"fxLink": "https://www.qweather.com/weather/beijing-101010100.html"
},
{
"name": "海淀",
"id": "101010200",
"lat": "39.95607",
"lon": "116.31032",
"adm2": "北京",
"adm1": "北京市",
"country": "中国",
"tz": "Asia/Shanghai",
"utcOffset": "+08:00",
"isDst": "0",
"type": "city",
"rank": "15",
"fxLink": "https://www.qweather.com/weather/haidian-101010200.html"
},
{
"name": "朝阳",
"id": "101010300",
"lat": "39.92149",
"lon": "116.48641",
"adm2": "北京",
"adm1": "北京市",
"country": "中国",
"tz": "Asia/Shanghai",
"utcOffset": "+08:00",
"isDst": "0",
"type": "city",
"rank": "15",
"fxLink": "https://www.qweather.com/weather/chaoyang-101010300.html"
},
{
"name": "顺义",
"id": "101010400",
"lat": "40.12894",
"lon": "116.65353",
"adm2": "北京",
"adm1": "北京市",
"country": "中国",
"tz": "Asia/Shanghai",
"utcOffset": "+08:00",
"isDst": "0",
"type": "city",
"rank": "33",
"fxLink": "https://www.qweather.com/weather/shunyi-101010400.html"
},
{
"name": "怀柔",
"id": "101010500",
"lat": "40.32427",
"lon": "116.63712",
"adm2": "北京",
"adm1": "北京市",
"country": "中国",
"tz": "Asia/Shanghai",
"utcOffset": "+08:00",
"isDst": "0",
"type": "city",
"rank": "33",
"fxLink": "https://www.qweather.com/weather/huairou-101010500.html"
},
{
"name": "通州",
"id": "101010600",
"lat": "39.90249",
"lon": "116.65860",
"adm2": "北京",
"adm1": "北京市",
"country": "中国",
"tz": "Asia/Shanghai",
"utcOffset": "+08:00",
"isDst": "0",
"type": "city",
"rank": "23",
"fxLink": "https://www.qweather.com/weather/tongzhou-101010600.html"
},
{
"name": "昌平",
"id": "101010700",
"lat": "40.21809",
"lon": "116.23591",
"adm2": "北京",
"adm1": "北京市",
"country": "中国",
"tz": "Asia/Shanghai",
"utcOffset": "+08:00",
"isDst": "0",
"type": "city",
"rank": "23",
"fxLink": "https://www.qweather.com/weather/changping-101010700.html"
},
{
"name": "延庆",
"id": "101010800",
"lat": "40.46532",
"lon": "115.98501",
"adm2": "北京",
"adm1": "北京市",
"country": "中国",
"tz": "Asia/Shanghai",
"utcOffset": "+08:00",
"isDst": "0",
"type": "city",
"rank": "33",
"fxLink": "https://www.qweather.com/weather/yanqing-101010800.html"
},
{
"name": "丰台",
"id": "101010900",
"lat": "39.86364",
"lon": "116.28696",
"adm2": "北京",
"adm1": "北京市",
"country": "中国",
"tz": "Asia/Shanghai",
"utcOffset": "+08:00",
"isDst": "0",
"type": "city",
"rank": "25",
"fxLink": "https://www.qweather.com/weather/fengtai-101010900.html"
},
{
"name": "石景山",
"id": "101011000",
"lat": "39.91460",
"lon": "116.19544",
"adm2": "北京",
"adm1": "北京市",
"country": "中国",
"tz": "Asia/Shanghai",
"utcOffset": "+08:00",
"isDst": "0",
"type": "city",
"rank": "35",
"fxLink": "https://www.qweather.com/weather/shijingshan-101011000.html"
}
],
"refer": {
"sources": [
"QWeather"
],
"license": [
"QWeather Developers License"
]
}
}
Query
1
Body
none:不发送任何Body数据,适用于GET请求或不需要Body的API
from-data:使用multipart/form-data格式发送数据,适用于上传文件或包含多种数据类型的请求
x-www-form-urlencoded:使用application/x-www-form-urlencoded格式发送数据,适用于简单的键值对数据
json:使用application/json格式发送数据,适用于复杂数据结构
xml:使用application/xml格式发送数据,适用于XML格式的API
raw:发送原始文本数据,可自定义Content-Type
请根据API要求选择合适的Body类型,并在下方输入对应格式的数据
接口响应
等待发起...
| 响应码 | 说明 |
|---|---|
| 200 | 请求成功 |
| 203 | 秘钥错误或不存在 |
| 204 | 服务器错误 |
| 211 | 接口不存在 |
| 212 | 当前接口已下架 |
| 213 | 当前接口正处于审核期 |
| 214 | API本地文件不存在,请联系管理员检查 |
| 215 | 管理员设置当前接口必须携带ckey请求! |
| 216 | 付费接口请携带ckey请求! |
| 217 | ckey不存在! |
| 218 | 当前ckey无权限调用此接口,请将此接口添加到ckey调用能力中后重试! |
| 219 | 访问频率超过限制!请稍后重试! |
| 220 | 本地API逻辑错误!请联系管理员检查! |
| 221 | 状态码与管理员配置的状态码不一致,请联系管理员! |
| 222 | 禁止访问!请联系管理员 (已被加入黑名单) |
| 223 | 积分不足!请充值后重试 |
| 224 | 余额不足!请充值后重试 |
| 225 | 您已设置仅白名单ip访问!请将当前ip添加到白名单中 |
选择编程语言

Node.js

cURL

PHP

Java

Go

Python

Fetch

C#
代码示例
异常情况
联系QQ
