通过官方渠道进行查询实况信息。
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| key | string | 是 | 接口调用密钥 | |
| msg | string | 是 | 查询天气的城市名称 | 北京 |
| unit | string | 否 | (可选,默认值),温度单位,c=摄氏度,f=华氏度 | c |
[
{
"name": "key",
"type": "string",
"required": true,
"description": "接口调用密钥",
"example": ""
},
{
"name": "msg",
"type": "string",
"required": true,
"description": "查询天气的城市名称",
"example": "北京"
},
{
"name": "unit",
"type": "string",
"required": false,
"description": "(可选,默认值),温度单位,c=摄氏度,f=华氏度",
"example": "c"
}
]
{
"openapi": "3.1.1",
"info": {
"title": "心知天气信息查询",
"description": "通过官方渠道进行查询实况信息。",
"version": "1.0.0"
},
"paths": {
"/api/yljk/zxtqcx/api.php": {
"get": {
"summary": "心知天气信息查询",
"description": "通过官方渠道进行查询实况信息。",
"parameters": [
{
"name": "key",
"in": "query",
"required": true,
"schema": {
"type": "string"
},
"description": "接口调用密钥"
},
{
"name": "msg",
"in": "query",
"required": true,
"schema": {
"type": "string",
"example": "北京"
},
"description": "查询天气的城市名称"
},
{
"name": "unit",
"in": "query",
"required": false,
"schema": {
"type": "string",
"example": "c"
},
"description": "(可选,默认值),温度单位,c=摄氏度,f=华氏度"
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
},
"post": {
"summary": "心知天气信息查询",
"description": "通过官方渠道进行查询实况信息。",
"parameters": [
{
"name": "key",
"in": "query",
"required": true,
"schema": {
"type": "string"
},
"description": "接口调用密钥"
},
{
"name": "msg",
"in": "query",
"required": true,
"schema": {
"type": "string",
"example": "北京"
},
"description": "查询天气的城市名称"
},
{
"name": "unit",
"in": "query",
"required": false,
"schema": {
"type": "string",
"example": "c"
},
"description": "(可选,默认值),温度单位,c=摄氏度,f=华氏度"
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
}
}
},
"servers": [
{
"url": "https://api-v2.317ak.com",
"description": "当前访问入口(https)"
}
]
}
{
"status": "success",
"code": 200,
"name": "北京",
"country": "CN",
"timezone": "Asia/Shanghai",
"text": "晴",
"weather_code": "0(晴)",
"temperature": "21℃",
"update_time": "2026-10-01 12:54:07",
"tis": "数据来源心知天气"
}
通过官方渠道进行天气实况信息查询,获取指定城市的当前天气数据。
适用于需要查询城市天气信息的应用场景。
https://api-v2.317ak.com/api/yljk/zxtqcx/api.php
支持请求方式:
接口调用需要提供密钥。
首选鉴权方式:Query
请求时通过 Query 参数传递密钥:
key=接口调用密钥
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| key | string | 是 | 接口调用密钥 |
| msg | string | 是 | 查询天气的城市名称,例如:北京 |
| unit | string | 否 | 温度单位,默认值为摄氏度;c 表示摄氏度,f 表示华氏度,例如:c |
{
"status": "success",
"code": 200,
"name": "北京",
"country": "CN",
"timezone": "Asia/Shanghai",
"text": "晴",
"weather_code": "0(晴)",
"temperature": "21℃",
"update_time": "2026-10-01 12:54:07",
"tis": "数据来源心知天气"
}
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 请求状态,成功时返回 success |
| code | integer | 请求结果状态标识 |
| name | string | 查询的城市名称 |
| country | string | 城市所属国家或地区代码 |
| timezone | string | 城市所在时区 |
| text | string | 当前天气描述 |
| weather_code | string | 天气状态编码及描述 |
| temperature | string | 当前温度信息 |
| update_time | string | 天气数据更新时间 |
| tis | string | 数据说明信息 |
接口发生业务异常时,返回统一错误 JSON 格式:
{
"code":0,
"msg":"未提供调用密钥",
"errcode":11001
}
| errcode | 含义 |
|---|---|
| 11001 | 未提供调用密钥 |
| 11002 | 密钥错误 |
| 11003 | 密钥已禁用 |
| 11004 | 积分余额不足 |
| 11005 | 请求过于频繁(QPM 限制) |
| 11006 | 接口维护中 |
| 11007 | 接口已禁用 |
| 11008 | 接口不可用 |
| 11009 | 密钥校验暂不可用 |
| 11010 | 积分系统暂不可用 |
| 11011 | 收费接口须提供有效密钥 |
| 11012 | 鉴权方式错误 |
| 11013 | 接口不存在 |
| 11014 | ***地址无效 |
| 11015 | ***地址不允许 |
| 11016 | ***请求失败 |
| 11017 | 服务暂不可用 |
| 11018 | 请求方式不允许 |
| 11019 | 当前IP不在白名单内 |
| 11020 | 启用出口代理须提供有效密钥 |
| 11021 | 未配置可用出口代理 |
| 11022 | 出口代理不可用 |
| 11023 | 密钥已过期 |
| 11024 | 令牌分配积分不足 |
curl -G "https://api-v2.317ak.com/api/yljk/zxtqcx/api.php" \
--data-urlencode "key=你的接口调用密钥" \
--data-urlencode "msg=北京" \
--data-urlencode "unit=c"
// PHP
$url = "https://api-v2.317ak.com/api/yljk/zxtqcx/api.php?key=你的接口调用密钥&msg=北京&unit=c";
$response = file_get_contents($url);
echo $response;
key 参数进行鉴权,请确保参数填写正确,否则可能导致请求失败。msg 参数用于指定查询城市名称,请传入有效的城市名称,例如“北京”,避免使用无法识别的地点名称影响查询结果。unit 参数为可选项,默认使用摄氏度。如需返回华氏度,请传入 f;使用摄氏度时可传入 c 或保持默认。curl -G "https://api-v2.317ak.com/api/yljk/zxtqcx/api.php" \
--data-urlencode "key=YOUR_API_KEY" \
--data-urlencode "msg=北京" \
--data-urlencode "unit=c"