详细天气
其他 官方文档
我见过天气查询信息最全的,数据来源于小米
基本说明:
接口地址:https://weatherapi.market.xiaomi.com/wtr-v3/weather/all
返回格式:json
请求方式:get/post
请求示例:https://weatherapi.market.xiaomi.com/wtr-v3/weather/all?latitude=&longitude=&appKey=&sign=&locale=
请求参数说明:
名称 类型 必填 说明
atitude int 必填 纬度信息,可填固定值0
longitude int 必填 经度信息,可填固定值0
locationKey string 必填 weathercn: + 地区 city_num, city_num 详情,例:weathercn:101010100 表示北京
sign string 必填 签名值,固定值zUFJoAR2ZVrDy1vF3D07
isGlobal string 必填 固定值 false
locale string 必填 固定值 zh_cn
返回参数说明:
名称 类型 说明
- - 见json
JSON返回示例:
{
	"current": {
		"feelsLike": {
			"unit": "℃",
			"value": "26"
		},
		"humidity": {
			"unit": "%",
			"value": "73"
		},
		"pressure": {
			"unit": "hPa",
			"value": "1003"
		},
		"pubTime": "2021-08-03T09:23:21+08:00",
		"temperature": {
			"unit": "℃",
			"value": "26"
		},
		"uvIndex": "2",
		"visibility": {
			"unit": "km",
			"value": ""
		},
		"weather": "1",
		"wind": {
			"direction": {
				"unit": "°",
				"value": "224.0"
			},
			"speed": {
				"unit": "km/h",
				"value": "4.0"
			}
		}
	},
	"forecastDaily": {
		"aqi": {
			"brandInfo": {
				"brands": [{
					"brandId": "caiyun",
					"logo": "http://f5.market.mi-img.com/download/MiSafe/07fa34263d698a7a9a8050dde6a7c63f8f243dbf3/a.webp",
					"names": {
						"zh_TW": "彩雲天氣",
						"en_US": "彩云天气",
						"zh_CN": "彩云天气"
					},
					"url": ""
				}]
			},
			"pubTime": "2021-08-03T00:00:00+08:00",
			"status": 0,
			"value": [
				38,
				54,
				61,
				62,
				63,
				61,
				67,
				75,
				68,
				70,
				76,
				77,
				64,
				64,
				27
			]
		},
		"moonPhase": {
			"moonPhaseList": [
				65,
				72,
				79,
				86,
				93, -100, -93, -86, -79, -72, -65, -58, -50, -43, -36
			],
			"pubTime": "2021-08-03 04:50:03"
		},
		"precipitationProbability": {
			"status": 0,
			"value": [
				"25",
				"25",
				"8",
				"2",
				"1"
			]
		},
		"pubTime": "2021-08-03T09:00:00+08:00",
		"status": 0,
		"sunRiseSet": {
			"status": 0,
			"value": [{
					"from": "2021-08-03T05:13:00+08:00",
					"to": "2021-08-03T19:27:00+08:00"
				},
				{
					"from": "2021-08-04T05:14:00+08:00",
					"to": "2021-08-04T19:26:00+08:00"
				},
				{
					"from": "2021-08-05T05:15:00+08:00",
					"to": "2021-08-05T19:24:00+08:00"
				},
				{
					"from": "2021-08-06T05:16:00+08:00",
					"to": "2021-08-06T19:23:00+08:00"
				},
				{
					"from": "2021-08-07T05:17:00+08:00",
					"to": "2021-08-07T19:22:00+08:00"
				},
				{
					"from": "2021-08-08T05:18:00+08:00",
					"to": "2021-08-08T19:21:00+08:00"
				},
				{
					"from": "2021-08-09T05:19:00+08:00",
					"to": "2021-08-09T19:20:00+08:00"
				},
				{
					"from": "2021-08-10T05:20:00+08:00",
					"to": "2021-08-10T19:18:00+08:00"
				},
				{
					"from": "2021-08-11T05:21:00+08:00",
					"to": "2021-08-11T19:17:00+08:00"
				},
				{
					"from": "2021-08-12T05:22:00+08:00",
					"to": "2021-08-12T19:16:00+08:00"
				},
				{
					"from": "2021-08-13T05:23:00+08:00",
					"to": "2021-08-13T19:15:00+08:00"
				},
				{
					"from": "2021-08-14T05:24:00+08:00",
					"to": "2021-08-14T19:13:00+08:00"
				},
				{
					"from": "2021-08-15T05:25:00+08:00",
					"to": "2021-08-15T19:12:00+08:00"
				},
				{
					"from": "2021-08-16T05:25:00+08:00",
					"to": "2021-08-16T19:11:00+08:00"
				},
				{
					"from": "2021-08-17T05:26:00+08:00",
					"to": "2021-08-17T19:09:00+08:00"
				}
			]
		},
		"temperature": {
			"status": 0,
			"unit": "℃",
			"value": [{
					"from": "30",
					"to": "24"
				},
				{
					"from": "31",
					"to": "24"
				},
				{
					"from": "31",
					"to": "24"
				},
				{
					"from": "32",
					"to": "23"
				},
				{
					"from": "33",
					"to": "23"
				},
				{
					"from": "33",
					"to": "24"
				},
				{
					"from": "33",
					"to": "24"
				},
				{
					"from": "30",
					"to": "22"
				},
				{
					"from": "32",
					"to": "22"
				},
				{
					"from": "31",
					"to": "20"
				},
				{
					"from": "30",
					"to": "22"
				},
				{
					"from": "29",
					"to": "25"
				},
				{
					"from": "30",
					"to": "21"
				},
				{
					"from": "30",
					"to": "22"
				},
				{
					"from": "30",
					"to": "22"
				}
			]
		},
		"weather": {
			"status": 0,
			"value": [{
					"from": "1",
					"to": "4"
				},
				{
					"from": "1",
					"to": "1"
				},
				{
					"from": "2",
					"to": "1"
				},
				{
					"from": "0",
					"to": "0"
				},
				{
					"from": "0",
					"to": "0"
				},
				{
					"from": "0",
					"to": "1"
				},
				{
					"from": "1",
					"to": "2"
				},
				{
					"from": "7",
					"to": "7"
				},
				{
					"from": "0",
					"to": "1"
				},
				{
					"from": "7",
					"to": "7"
				},
				{
					"from": "1",
					"to": "1"
				},
				{
					"from": "2",
					"to": "7"
				},
				{
					"from": "7",
					"to": "7"
				},
				{
					"from": "1",
					"to": "2"
				},
				{
					"from": "7",
					"to": "7"
				}
			]
		},
		"wind": {
			"direction": {
				"status": 0,
				"unit": "°",
				"value": [{
						"from": "224.0",
						"to": "224.0"
					},
					{
						"from": "191.05",
						"to": "187.59"
					},
					{
						"from": "141.79",
						"to": "174.29"
					},
					{
						"from": "201.94",
						"to": "190.81"
					},
					{
						"from": "144.67",
						"to": "166.96"
					},
					{
						"from": "201.36",
						"to": "201.55"
					},
					{
						"from": "186.96",
						"to": "175.18"
					},
					{
						"from": "184.56",
						"to": "165.58"
					},
					{
						"from": "223.63",
						"to": "201.41"
					},
					{
						"from": "192.97",
						"to": "208.37"
					},
					{
						"from": "187.94",
						"to": "190.15"
					},
					{
						"from": "182.1",
						"to": "185.8"
					},
					{
						"from": "128.19",
						"to": "160.54"
					},
					{
						"from": "104.23",
						"to": "165.32"
					},
					{
						"from": "174.62",
						"to": "186.04"
					}
				]
			},
			"speed": {
				"status": 0,
				"unit": "km/h",
				"value": [{
						"from": "4.0",
						"to": "4.0"
					},
					{
						"from": "9.44",
						"to": "14.84"
					},
					{
						"from": "6.2",
						"to": "12.92"
					},
					{
						"from": "7.06",
						"to": "11.62"
					},
					{
						"from": "6.69",
						"to": "12.92"
					},
					{
						"from": "9.11",
						"to": "18.15"
					},
					{
						"from": "7.03",
						"to": "15.33"
					},
					{
						"from": "6.78",
						"to": "14.33"
					},
					{
						"from": "5.23",
						"to": "10.11"
					},
					{
						"from": "10.22",
						"to": "16.99"
					},
					{
						"from": "7.96",
						"to": "12.73"
					},
					{
						"from": "5.17",
						"to": "6.06"
					},
					{
						"from": "5.24",
						"to": "6.67"
					},
					{
						"from": "3.52",
						"to": "3.71"
					},
					{
						"from": "5.51",
						"to": "8.01"
					}
				]
			}
		}
	},
	"forecastHourly": {
		"aqi": {
			"brandInfo": {
				"brands": [{
					"brandId": "caiyun",
					"logo": "http://f5.market.mi-img.com/download/MiSafe/07fa34263d698a7a9a8050dde6a7c63f8f243dbf3/a.webp",
					"names": {
						"zh_TW": "彩雲天氣",
						"en_US": "彩云天气",
						"zh_CN": "彩云天气"
					},
					"url": ""
				}]
			},
			"pubTime": "2021-08-03T10:00:00+08:00",
			"status": 0,
			"value": [
				19,
				21,
				24,
				26,
				29,
				30,
				31,
				33,
				34,
				36,
				37,
				39,
				40,
				41,
				44,
				46,
				47,
				49,
				50,
				51,
				54,
				55,
				56
			]
		},
		"desc": "逐小时预报",
		"status": 0,
		"temperature": {
			"pubTime": "2021-08-03T10:00:00+08:00",
			"status": 0,
			"unit": "",
			"value": [
				28,
				30,
				30,
				30,
				30,
				30,
				30,
				29,
				29,
				29,
				28,
				27,
				27,
				26,
				26,
				25,
				25,
				25,
				24,
				24,
				24,
				25,
				25
			]
		},
		"weather": {
			"pubTime": "2021-08-03T10:00:00+08:00",
			"status": 0,
			"value": [
				1,
				1,
				1,
				1,
				1,
				1,
				1,
				1,
				1,
				1,
				1,
				2,
				2,
				2,
				2,
				2,
				4,
				2,
				2,
				2,
				2,
				2,
				2
			]
		},
		"wind": {
			"status": 0,
			"value": [{
					"datetime": "2021-08-03T10:00:00.000+08:00",
					"direction": "193.91",
					"speed": "6.19"
				},
				{
					"datetime": "2021-08-03T11:00:00.000+08:00",
					"direction": "186.46",
					"speed": "7.22"
				},
				{
					"datetime": "2021-08-03T12:00:00.000+08:00",
					"direction": "189.62",
					"speed": "7.92"
				},
				{
					"datetime": "2021-08-03T13:00:00.000+08:00",
					"direction": "197.55",
					"speed": "10.22"
				},
				{
					"datetime": "2021-08-03T14:00:00.000+08:00",
					"direction": "196.32",
					"speed": "12.03"
				},
				{
					"datetime": "2021-08-03T15:00:00.000+08:00",
					"direction": "187.83",
					"speed": "12.36"
				},
				{
					"datetime": "2021-08-03T16:00:00.000+08:00",
					"direction": "187.52",
					"speed": "12.96"
				},
				{
					"datetime": "2021-08-03T17:00:00.000+08:00",
					"direction": "177.62",
					"speed": "12.0"
				},
				{
					"datetime": "2021-08-03T18:00:00.000+08:00",
					"direction": "174.73",
					"speed": "12.13"
				},
				{
					"datetime": "2021-08-03T19:00:00.000+08:00",
					"direction": "169.48",
					"speed": "10.73"
				},
				{
					"datetime": "2021-08-03T20:00:00.000+08:00",
					"direction": "168.09",
					"speed": "10.01"
				},
				{
					"datetime": "2021-08-03T21:00:00.000+08:00",
					"direction": "174.51",
					"speed": "9.11"
				},
				{
					"datetime": "2021-08-03T22:00:00.000+08:00",
					"direction": "171.9",
					"speed": "9.62"
				},
				{
					"datetime": "2021-08-03T23:00:00.000+08:00",
					"direction": "180.36",
					"speed": "8.89"
				},
				{
					"datetime": "2021-08-04T00:00:00.000+08:00",
					"direction": "187.98",
					"speed": "7.2"
				},
				{
					"datetime": "2021-08-04T01:00:00.000+08:00",
					"direction": "168.32",
					"speed": "6.62"
				},
				{
					"datetime": "2021-08-04T02:00:00.000+08:00",
					"direction": "207.82",
					"speed": "8.23"
				},
				{
					"datetime": "2021-08-04T03:00:00.000+08:00",
					"direction": "201.88",
					"speed": "8.2"
				},
				{
					"datetime": "2021-08-04T04:00:00.000+08:00",
					"direction": "196.46",
					"speed": "7.75"
				},
				{
					"datetime": "2021-08-04T05:00:00.000+08:00",
					"direction": "187.85",
					"speed": "4.32"
				},
				{
					"datetime": "2021-08-04T06:00:00.000+08:00",
					"direction": "200.73",
					"speed": "4.07"
				},
				{
					"datetime": "2021-08-04T07:00:00.000+08:00",
					"direction": "190.43",
					"speed": "3.89"
				},
				{
					"datetime": "2021-08-04T08:00:00.000+08:00",
					"direction": "202.83",
					"speed": "5.17"
				}
			]
		}
	},
	"indices": {
		"indices": [{
				"type": "uvIndex",
				"value": "5"
			},
			{
				"type": "humidity",
				"value": "73"
			},
			{
				"type": "feelsLike",
				"value": "26"
			},
			{
				"type": "pressure",
				"value": "1003"
			},
			{
				"type": "carWash",
				"value": "1"
			},
			{
				"type": "sports",
				"value": "1"
			}
		],
		"pubTime": "",
		"status": 0
	},
	"alerts": [],
	"yesterday": {
		"aqi": "",
		"date": "2021-08-02T12:00:00+08:00",
		"status": 0,
		"sunRise": "2021-08-02T05:12:00+08:00",
		"sunSet": "2021-08-02T19:28:00+08:00",
		"tempMax": "32",
		"tempMin": "23",
		"weatherEnd": "1",
		"weatherStart": "0",
		"windDircEnd": "90",
		"windDircStart": "0",
		"windSpeedEnd": "0.0",
		"windSpeedStart": "0.0"
	},
	"url": {
		"weathercn": "",
		"caiyun": ""
	},
	"brandInfo": {
		"brands": [{
				"brandId": "caiyun",
				"logo": "http://f5.market.mi-img.com/download/MiSafe/069835733640846b1b2613a855328d2b6df404343/a.webp",
				"names": {
					"zh_TW": "彩雲天氣",
					"en_US": "彩云天气",
					"zh_CN": "彩云天气"
				},
				"url": ""
			},
			{
				"brandId": "weatherbj",
				"logo": "",
				"names": {
					"zh_TW": "北京气象局",
					"en_US": "北京气象局",
					"zh_CN": "北京气象局"
				},
				"url": ""
			}
		]
	},
	"preHour": [{
		"feelsLike": {
			"unit": "℃",
			"value": "25"
		},
		"humidity": {
			"unit": "%",
			"value": "72"
		},
		"pressure": {
			"unit": "hPa",
			"value": "1003"
		},
		"pubTime": "2021-08-03T09:00:00+08:00",
		"temperature": {
			"unit": "℃",
			"value": "26"
		},
		"uvIndex": "2",
		"visibility": {
			"unit": "km",
			"value": ""
		},
		"weather": "1",
		"wind": {
			"direction": {
				"unit": "°",
				"value": "0.0"
			},
			"speed": {
				"unit": "km/h",
				"value": "2.0"
			}
		},
		"aqi": {
			"aqi": "36",
			"brandInfo": {
				"brands": [{
					"brandId": "CNEMC",
					"logo": "",
					"names": {
						"zh_TW": "中國環境監測總站",
						"en_US": "CNEMC",
						"zh_CN": "中国环境监测总站"
					},
					"url": ""
				}]
			},
			"co": "1.2",
			"no2": "17",
			"o3": "33",
			"pm10": "36",
			"pm25": "12",
			"primary": "",
			"pubTime": "2021-08-03T08:40:10+08:00",
			"so2": "5",
			"src": "中国环境监测总站",
			"status": 0,
			"suggest": "空气很好,快呼吸新鲜空气,拥抱大自然吧",
			"pm25Desc": "PM2.5指的是直径小于或等于2.5微米的颗粒物,又称为细颗粒物",
			"pm10Desc": "PM10的主要来源是建筑活动和从地表扬起的尘土,含有氧化物矿物和其他成分",
			"no2Desc": "二氧化氮的主要来源是燃烧过程产生,例如供热、发电以及机动车和船舶的发动机",
			"so2Desc": "二氧化硫影响呼吸系统和肺功能,并刺激眼睛。呼吸道的炎症导致咳嗽、粘液分泌、加重哮喘和慢性支气管炎",
			"coDesc": "一氧化碳是无色,无臭,无味气体,但吸入对人体有十分大的危害",
			"o3Desc": "地面的臭氧主要由车辆和工业释放出的氧化氮等污染物以及由机动车、溶剂和工业释放的挥发性有机化合物与阳光反应而生成"
		}
	}],
	"sourceMaps": {
		"current": {
			"feelsLike": "weatherbj(locationKey=101010100)",
			"weather": "weatherbj(locationKey=101010100)",
			"temperature": "weatherbj(locationKey=101010100)",
			"humidity": "weatherbj(locationKey=101010100)",
			"pressure": "weatherbj(locationKey=101010100)",
			"windDir": "caiyun(locationKey=101010100)",
			"windSpeed": "caiyun(locationKey=101010100)",
			"uvIndex": "accucn(locationKey=57460,locale=zh_CN)"
		},
		"indices": {
			"feelsLikeV1": "weatherbj(locationKey=101010100)",
			"pressureV1": "weatherbj(locationKey=101010100)",
			"uvIndexV1": "weatherbj(locationKey=101010100)",
			"sportsV1": "weatherbj(locationKey=101010100)",
			"carWashV1": "weatherbj(locationKey=101010100)"
		},
		"daily": {
			"preciProbability": "accucn(locationKey=57460,locale=zh_CN)",
			"weather": "weatherbj(locationKey=101010100)",
			"temperature": "weatherbj(locationKey=101010100)",
			"sunRiseSet": "weatherbj(locationKey=101010100)",
			"aqi": "caiyun(locationKey=39.904,116.408,locale=zh_CN)",
			"wind": "caiyun(locationKey=101010100)"
		},
		"clientInfo": {
			"appVersion": 12060802,
			"isLocated": false,
			"isGlobal": false,
			"appKey": "weather20151024",
			"locale": "zh_CN"
		},
		"hourly": {
			"weather": "weatherbj(locationKey=101010100)",
			"temperature": "weatherbj(locationKey=101010100)",
			"aqi": "caiyun(locationKey=39.904,116.408,locale=zh_CN)",
			"wind": "caiyun(locationKey=39.904,116.408, latitude=null, longitude=null)",
			"desc": "caiyun(locationKey=39.904,116.408, latitude=null, longitude=null)"
		}
	},
	"updateTime": 1627954796986,
	"aqi": {
		"aqi": "38",
		"brandInfo": {
			"brands": [{
				"brandId": "CNEMC",
				"logo": "",
				"names": {
					"zh_TW": "中國環境監測總站",
					"en_US": "CNEMC",
					"zh_CN": "中国环境监测总站"
				},
				"url": ""
			}]
		},
		"co": "1.2",
		"no2": "17",
		"o3": "40",
		"pm10": "38",
		"pm25": "15",
		"primary": "",
		"pubTime": "2021-08-03T09:30:00+08:00",
		"so2": "5",
		"src": "中国环境监测总站",
		"status": 0,
		"suggest": "空气很好,快呼吸新鲜空气,拥抱大自然吧",
		"pm25Desc": "PM2.5易携带重金属、微生物等有害物质,对人体健康影响较大",
		"pm10Desc": "PM10的主要来源是建筑活动和从地表扬起的尘土,含有氧化物矿物和其他成分",
		"no2Desc": "二氧化氮的主要来源是燃烧过程产生,例如供热、发电以及机动车和船舶的发动机",
		"so2Desc": "二氧化硫影响呼吸系统和肺功能,并刺激眼睛。呼吸道的炎症导致咳嗽、粘液分泌、加重哮喘和慢性支气管炎",
		"coDesc": "一氧化碳八成来自汽车尾气,交通高峰期时,公路沿线产生的CO浓度会高于平常",
		"o3Desc": "地面的臭氧主要由车辆和工业释放出的氧化氮等污染物以及由机动车、溶剂和工业释放的挥发性有机化合物与阳光反应而生成"
	}
}
服务级错误码参照
错误码 说明
5 必填参数未填
8 locationKey信息不可用
完整教学代码示例
<?php
/**
 * Created by PhpStorm.
 * User: FZS
 * Time: 2021/08/02 22:26
 */
class freeApi
{
    private $apiUrl;

    public function __construct()
    {
        $this->apiUrl = 'https://weatherapi.market.xiaomi.com/wtr-v3/weather/all?latitude=110&longitude=112&locationKey=weathercn%3A101010100&appKey=weather20151024&sign=zUFJoAR2ZVrDy1vF3D07&isGlobal=false&locale=zh_cn';
    }

    /**
     * 获取结果
     * @return array
     */
    public function getResult()
    {
        return file_get_contents($this->apiUrl);
    }
}
package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
)

const (
	APIURL   = "https://weatherapi.market.xiaomi.com/wtr-v3/weather/all?latitude=110&longitude=112&locationKey=weathercn%3A101010100&appKey=weather20151024&sign=zUFJoAR2ZVrDy1vF3D07&isGlobal=false&locale=zh_cn"
)

func main() {
	queryUrl := fmt.Sprintf("%s",APIURL)
	resp, err := http.Get(queryUrl)
	if err != nil {
		log.Println(err)
		return
	}

	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)

	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(string(body))
}