多平台天气查询,支持墨迹、百度、中国天气、中央气象台、彩云天气,返回实时与预报数据。
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| city | string | 是 | 城市名 | 渠县 |
| days | string | 否 | 预报天数 | 7 |
| type | string | 否 | 平台:墨迹天气(moji)、百度天气(baidu)、中国天气(zgtq)、中央气象台(zytq)、彩云天气(cytq) | cytq |
[
{
"name": "city",
"type": "string",
"required": true,
"description": "城市名",
"example": "渠县"
},
{
"name": "days",
"type": "string",
"required": false,
"description": "预报天数",
"example": "7"
},
{
"name": "type",
"type": "string",
"required": false,
"description": "平台:墨迹天气(moji)、百度天气(baidu)、中国天气(zgtq)、中央气象台(zytq)、彩云天气(cytq)",
"example": "cytq"
}
]
{
"openapi": "3.1.1",
"info": {
"title": "天气查询",
"description": "多平台天气查询,支持墨迹、百度、中国天气、中央气象台、彩云天气,返回实时与预报数据。",
"version": "1.0.0"
},
"paths": {
"\/api\/weather\/index.php": {
"get": {
"summary": "天气查询",
"description": "多平台天气查询,支持墨迹、百度、中国天气、中央气象台、彩云天气,返回实时与预报数据。",
"parameters": [
{
"name": "city",
"in": "query",
"required": true,
"schema": {
"type": "string",
"example": "渠县"
},
"description": "城市名"
},
{
"name": "days",
"in": "query",
"required": false,
"schema": {
"type": "string",
"example": "7"
},
"description": "预报天数"
},
{
"name": "type",
"in": "query",
"required": false,
"schema": {
"type": "string",
"example": "cytq"
},
"description": "平台:墨迹天气(moji)、百度天气(baidu)、中国天气(zgtq)、中央气象台(zytq)、彩云天气(cytq)"
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application\/json": {
"schema": {
"type": "object"
}
}
}
}
}
},
"post": {
"summary": "天气查询",
"description": "多平台天气查询,支持墨迹、百度、中国天气、中央气象台、彩云天气,返回实时与预报数据。",
"parameters": [
{
"name": "city",
"in": "query",
"required": true,
"schema": {
"type": "string",
"example": "渠县"
},
"description": "城市名"
},
{
"name": "days",
"in": "query",
"required": false,
"schema": {
"type": "string",
"example": "7"
},
"description": "预报天数"
},
{
"name": "type",
"in": "query",
"required": false,
"schema": {
"type": "string",
"example": "cytq"
},
"description": "平台:墨迹天气(moji)、百度天气(baidu)、中国天气(zgtq)、中央气象台(zytq)、彩云天气(cytq)"
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application\/json": {
"schema": {
"type": "object"
}
}
}
}
}
}
}
},
"servers": [
{
"url": "https:\/\/api.vsaa.cn",
"description": "当前访问入口(https)"
}
]
}
{
"code": 200,
"success": true,
"city": "渠县",
"location": {
"name": "中国 四川省 达州市 渠县",
"longitude": 106.970746,
"latitude": 30.836348
},
"current": {
"temperature": 35.21,
"feels_like": 36.6,
"humidity": 34,
"pressure": 97713.44,
"visibility": 30.08,
"wind_direction": 51.15,
"wind_speed": 6.66,
"weather": "CLEAR_DAY",
"air_quality": {
"aqi": 45,
"pm25": 19,
"description": "优"
},
"life_index": {
"ultraviolet": "强",
"comfort": "很热"
}
},
"forecast": [
{
"date": "2026-09-03T00:00+08:00",
"weather": "CLEAR_DAY",
"max_temp": 35.21,
"min_temp": 21.69,
"wind_direction": 26.89,
"wind_speed": 6.57,
"humidity": 0.51,
"precipitation": 0
},
{
"date": "2026-09-04T00:00+08:00",
"weather": "CLEAR_DAY",
"max_temp": 36.07,
"min_temp": 23.46,
"wind_direction": 324.96,
"wind_speed": 6.03,
"humidity": 0.59,
"precipitation": 0
},
{
"date": "2026-09-05T00:00+08:00",
"weather": "PARTLY_CLOUDY_DAY",
"max_temp": 36.98,
"min_temp": 25.27,
"wind_direction": 106.88,
"wind_speed": 5.77,
"humidity": 0.61,
"precipitation": 0
},
{
"date": "2026-09-06T00:00+08:00",
"weather": "PARTLY_CLOUDY_DAY",
"max_temp": 36.67,
"min_temp": 26.44,
"wind_direction": 89.3,
"wind_speed": 6.94,
"humidity": 0.62,
"precipitation": 0
},
{
"date": "2026-09-07T00:00+08:00",
"weather": "CLOUDY",
"max_temp": 36.86,
"min_temp": 25.35,
"wind_direction": 87.31,
"wind_speed": 7.02,
"humidity": 0.57,
"precipitation": 0
},
{
"date": "2026-09-08T00:00+08:00",
"weather": "CLOUDY",
"max_temp": 36.77,
"min_temp": 25.44,
"wind_direction": 359.13,
"wind_speed": 7.17,
"humidity": 0.59,
"precipitation": 0
},
{
"date": "2026-09-09T00:00+08:00",
"weather": "HEAVY_RAIN",
"max_temp": 31.11,
"min_temp": 25.15,
"wind_direction": 0.13,
"wind_speed": 8.15,
"humidity": 0.76,
"precipitation": 1.5457
}
],
"summary": {
"key_point": "未来两小时不会下雨,放心出门吧",
"hourly_description": "晴,今天夜里24点钟后转多云,其后晴"
}
}
本接口提供多平台天气数据聚合查询服务,支持墨迹天气、百度天气、中国天气网、中央气象台及彩云天气等多种数据源。面向需要快速获取城市实时天气及未来预报的开发者开放,无需鉴权即可调用。接口返回当前天气、空气质量、生活指数及逐日预报等结构化数据,便于快速集成至各类应用。
/api/weather/index.php
支持 GET 和 POST 两种请求方式。
本接口无需密钥即可调用。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| city | string | 是 | 目标城市名称,如 渠县 |
| days | string | 否 | 预报天数,默认 7 天 |
| type | string | 否 | 数据来源平台,可选值:moji(墨迹天气)、baidu(百度天气)、zgtq(中国天气)、zytq(中央气象台)、cytq(彩云天气) |
{
"code": 200,
"success": true,
"city": "渠县",
"location": {
"name": "中国 四川省 达州市 渠县",
"longitude": 106.970746,
"latitude": 30.836348
},
"current": {
"temperature": 35.21,
"feels_like": 36.6,
"humidity": 34,
"pressure": 97713.44,
"visibility": 30.08,
"wind_direction": 51.15,
"wind_speed": 6.66,
"weather": "CLEAR_DAY",
"air_quality": {
"aqi": 45,
"pm25": 19,
"description": "优"
},
"life_index": {
"ultraviolet": "强",
"comfort": "很热"
}
},
"forecast": [
{
"date": "2026-09-03T00:00+08:00",
"weather": "CLEAR_DAY",
"max_temp": 35.21,
"min_temp": 21.69,
"wind_direction": 26.89,
"wind_speed": 6.57,
"humidity": 0.51,
"precipitation": 0
},
{
"date": "2026-09-04T00:00+08:00",
"weather": "CLEAR_DAY",
"max_temp": 36.07,
"min_temp": 23.46,
"wind_direction": 324.96,
"wind_speed": 6.03,
"humidity": 0.59,
"precipitation": 0
},
{
"date": "2026-09-05T00:00+08:00",
"weather": "PARTLY_CLOUDY_DAY",
"max_temp": 36.98,
"min_temp": 25.27,
"wind_direction": 106.88,
"wind_speed": 5.77,
"humidity": 0.61,
"precipitation": 0
}
],
"summary": {
"key_point": "未来两小时不会下雨,放心出门吧",
"hourly_description": "晴,今天夜里24点钟后转多云,其后晴"
}
}
| 字段 | 类型 | 说明 |
|---|---|---|
| code | number | 状态码,200 表示请求成功 |
| success | boolean | 请求是否成功 |
| city | string | 查询的城市名称 |
| location | object | 地理位置信息 |
| location.name | string | 完整地理位置描述 |
| location.longitude | number | 经度 |
| location.latitude | number | 纬度 |
| current | object | 当前天气数据 |
| current.temperature | number | 当前温度(℃) |
| current.feels_like | number | 体感温度(℃) |
| current.humidity | number | 相对湿度(%) |
| current.pressure | number | 大气压强(Pa) |
| current.visibility | number | 能见度(km) |
| current.wind_direction | number | 风向(角度,0°-360°) |
| current.wind_speed | number | 风速(m/s) |
| current.weather |
{
"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 | 出口代理不可用 |
curl "https://your-domain.com/api/weather/index.php?city=渠县&days=7&type=cytq"
// PHP
$city = '渠县';
$days = 7;
$type = 'cytq';
$url = 'https://your-domain.com/api/weather/index.php?city=' . urlencode($city)
. '&days=' . $days
. '&type=' . urlencode($type);
$response = file_get_contents($url);
$data = json_decode($response, true);
echo '城市:' . $data['city'] . PHP_EOL;
echo '当前温度:' . $data['current']['temperature'] . '°C' . PHP_EOL;
echo '预报天数:' . count($data['forecast']) . '天' . PHP_EOL;
city 参数支持中文城市名,建议传入标准名称(如「渠县」「北京」),模糊或错误地名可能导致查询失败或返回误差较大数据。days 为可选参数,默认为 7 天预报,可指定其他天数,建议不超过 15 天以保证数据准确性。type 参数控制数据来源平台,可选值为:moji(墨迹天气)、baidu(百度天气)、zgtq(中国天气)、zytq(中央气象台)、cytq(彩云天气),各平台数据更新频率和覆盖范围略有差异,可依据实际需求切换。weather 字段为枚举值(如 CLEAR_DAY、PARTLY_CLOUDY_DAY、CLOUDY、HEAVY_RAIN 等),前端可据此映射为对应天气图标。aqi 与 pm25 数据部分平台可能缺失,读取时建议做空值兼容处理。curl "http://localhost/api/weather/index.php?city=渠县&days=7&type=cytq"
欢迎使用 万象数据API(以下简称“本平台”,域名为 api.vsaa.cn)。在使用本平台提供的任何接口、数据及相关服务之前,请您务必仔细阅读并充分理解本免责声明的全部内容。您对本平台任何服务的使用,均视为您已阅读、理解并同意本声明的全部条款。
最后更新日期:2026年10月6日