真正免费的天气API,无需注册申请key

抱歉,已失效……………………

文章目录

      • 1.中华万年历的天气API
      • 2.讯飞语音识别内置的墨迹天气API
      • 3.乐享天气APP

无聊整理的真正免费的天气API,无需注册申请key等,当然部分数据解析需要自己理解下,也不是所有天气数据都有,如果有特别需求,还是使用各个收费的天气供应商支持。这仅分享各开发者学习测试使用。

1.中华万年历的天气API

url:http://wthrcdn.etouch.cn/WeatherApi?city=城市名http://wthrcdn.etouch.cn/WeatherApi?citykey=城市代码,平常使用觉得直接传对应城市名更方便些,citykey还需要查找。
返回的数据是XML格式,
1.支持的数据当时温度、湿度、风力、风向、日出时间、日落时间;
2.支持前一天和未来五天的数据,包含高-低温,白天天气和夜晚天气;
3.支持一些天气指数提示和建议,包括穿衣指数,紫外线指数,运动指数等;
例如,查询上海的天气
http://wthrcdn.etouch.cn/WeatherApi?city=上海
返回结果:

<resp>
  <city>上海city>
  <updatetime>16:46updatetime>
  <wendu>28wendu>
  <fengli>
    
  fengli>
  <shidu>43%shidu>
  <fengxiang>东南风fengxiang>
  <sunrise_1>04:49sunrise_1>
  <sunset_1>18:57sunset_1>
  <sunrise_2/>
  <sunset_2/>
  <yesterday>
    <date_1>7日星期二date_1>
    <high_1>高温 28℃high_1>
    <low_1>低温 18℃low_1>
    <day_1>
      <type_1>type_1>
      <fx_1>北风fx_1>
      <fl_1>
        
      fl_1>
    day_1>
    <night_1>
      <type_1>多云type_1>
      <fx_1>北风fx_1>
      <fl_1>
        
      fl_1>
    night_1>
  yesterday>
  <forecast>
    <weather>
      <date>8日星期三date>
      <high>高温 28℃high>
      <low>低温 20℃low>
      <day>
        <type>多云type>
        <fengxiang>东南风fengxiang>
        <fengli>
          
        fengli>
      day>
      <night>
        <type>多云type>
        <fengxiang>东南风fengxiang>
        <fengli>
          
        fengli>
      night>
    weather>
    <weather>
      <date>9日星期四date>
      <high>高温 25℃high>
      <low>低温 20℃low>
      <day>
        <type>type>
        <fengxiang>东南风fengxiang>
        <fengli>
          
        fengli>
      day>
      <night>
        <type>type>
        <fengxiang>东南风fengxiang>
        <fengli>
          
        fengli>
      night>
    weather>
    <weather>
      <date>10日星期五date>
      <high>高温 22℃high>
      <low>低温 20℃low>
      <day>
        <type>大雨type>
        <fengxiang>东风fengxiang>
        <fengli>
          
        fengli>
      day>
      <night>
        <type>小雨type>
        <fengxiang>东风fengxiang>
        <fengli>
          
        fengli>
      night>
    weather>
    <weather>
      <date>11日星期六date>
      <high>高温 26℃high>
      <low>低温 20℃low>
      <day>
        <type>小雨type>
        <fengxiang>东风fengxiang>
        <fengli>
          
        fengli>
      day>
      <night>
        <type>多云type>
        <fengxiang>东风fengxiang>
        <fengli>
          
        fengli>
      night>
    weather>
    <weather>
      <date>12日星期天date>
      <high>高温 26℃high>
      <low>低温 20℃low>
      <day>
        <type>小雨type>
        <fengxiang>东风fengxiang>
        <fengli>
          
        fengli>
      day>
      <night>
        <type>type>
        <fengxiang>东风fengxiang>
        <fengli>
          
        fengli>
      night>
    weather>
  forecast>
  <zhishus>
    <zhishu>
      <name>穿衣指数name>
      <value>薄款春夏装value>
      <detail>天气舒适,建议穿着薄款,透气的衣物。推荐:长T、长裙、长裤等。detail>
    zhishu>
    <zhishu>
      <name>紫外线强度name>
      <value>紫外线较弱value>
      <detail>紫外线强度弱,外出记得涂防晒霜,避免皮肤受到太阳辐射的危害。detail>
    zhishu>
    <zhishu>
      <name>护肤指数name>
      <value>常规护肤value>
      <detail>空气适宜,请根据皮肤类型,选择适合的常规护肤品。detail>
    zhishu>
    <zhishu>
      <name>洗车指数name>
      <value>较适宜洗车value>
      <detail>今明两日天气较好,可以放心洗车。detail>
    zhishu>
    <zhishu>
      <name>感冒指数name>
      <value>少发感冒value>
      <detail>感冒低发期,天气舒适,请注意多吃蔬菜水果,多喝水哦。detail>
    zhishu>
    <zhishu>
      <name>晾晒指数name>
      <value>较适宜晾晒value>
      <detail>预计白天没有降水,温度适宜,较适合晾晒.detail>
    zhishu>
    <zhishu>
      <name>户外指数name>
      <value>较适宜外出value>
      <detail>天气还可以,预计白天没有降水,适合参加户外活动,适当锻炼身体。detail>
    zhishu>
    <zhishu>
      <name>污染指数name>
      <value>无污染value>
      <detail>空气很好,污染物浓度低,可在户外正常活动,对健康人群无明显影响。detail>
    zhishu>
    <zhishu>
      <name>钓鱼指数name>
      <value>适宜value>
      <detail>这样的天气非常适宜外出钓鱼,约个钓友出去钓鱼吧。detail>
    zhishu>
    <zhishu>
      <name>中暑指数name>
      <value>不易中暑value>
      <detail>预计今日整体天气适中,中暑的可能性较低,无需做特殊防护。detail>
    zhishu>
    <zhishu>
      <name>舒适度name>
      <value>一般舒适value>
      <detail>天气变热,少部分人可能会不舒适。detail>
    zhishu>
    <zhishu>
      <name>赏月指数name>
      <value>较适宜赏月value>
      <detail>今晚条件尚可,可以赏月detail>
    zhishu>
  zhishus>
resp>

2.讯飞语音识别内置的墨迹天气API

url:http://autodev.openspeech.cn/csp/api/v2.1/weather?openId=aiuicus&clientType=android&sign=android&city=上海&latitude=39.902895&longitude=116.427915&needMoreData=true&pageNo=1&pageSize=7
支持通过城市名直接查询或者通过经纬度查询,city和经纬度经过一种方式即可。

注意:url中的openId、clientType以及sign等参数具体含义我也不清楚,但写此文档时如上参数是必需的,否则请求失败;具体传什么值好像并没影响。

返回数据为json格式;支持未来7天的数据查询,支持的数据有天气、温度、湿度、PM2.5、PM10、空气指数、空气质量、日出时间、日落时间等;
例如查询上海数据:http://autodev.openspeech.cn/csp/api/v2.1/weather?openId=aiuicus&clientType=android&sign=android&city=上海&needMoreData=true&pageNo=1&pageSize=7

{
  "code": 0,
  "msg": "操作成功",
  "data": {
    "total": 7,
    "sourceName": "墨迹天气",
    "list": [
      {
        "city": "上海",
        "lastUpdateTime": "2022-06-08 16:55:08",
        "date": "2022-06-08",
        "weather": "多云",
        "temp": 27.0,
        "humidity": "42%",
        "wind": "西风2级",
        "pm25": 19.0,
        "pm10": 25.0,
        "low": 20.0,
        "high": 28.0,
        "airData": "43",
        "airQuality": "优",
        "dateLong": 1654617600000,
        "weatherType": 1,
        "windLevel": 2,
        "province": "上海",
        "moreData": {
          "sunrise": "2022-06-08 04:50:00",
          "sunset": "2022-06-08 18:57:00",
          "precipitation": "0",
          "alert": null
        }
      },
      {
        "city": "上海",
        "lastUpdateTime": "2022-06-08 16:09:00",
        "date": "2022-06-09",
        "weather": "晴",
        "humidity": "未知",
        "wind": "南风",
        "pm25": 0.0,
        "low": 20.0,
        "high": 25.0,
        "airData": "59",
        "airQuality": "良",
        "dateLong": 1654704000000,
        "weatherType": 0,
        "windLevel": 3,
        "province": "上海",
        "moreData": {
          "sunrise": "2022-06-09 04:49:00",
          "sunset": "2022-06-09 18:57:00",
          "precipitation": null,
          "alert": null
        }
      },
      {
        "city": "上海",
        "lastUpdateTime": "2022-06-08 16:09:00",
        "date": "2022-06-10",
        "weather": "大雨",
        "humidity": "未知",
        "wind": "东南风",
        "pm25": 0.0,
        "low": 20.0,
        "high": 22.0,
        "airData": "46",
        "airQuality": "优",
        "dateLong": 1654790400000,
        "weatherType": 9,
        "windLevel": 3,
        "province": "上海",
        "moreData": {
          "sunrise": "2022-06-10 04:49:00",
          "sunset": "2022-06-10 18:58:00",
          "precipitation": null,
          "alert": null
        }
      },
      {
        "city": "上海",
        "lastUpdateTime": "2022-06-08 16:09:00",
        "date": "2022-06-11",
        "weather": "多云",
        "humidity": "未知",
        "wind": "东风",
        "pm25": 0.0,
        "low": 20.0,
        "high": 26.0,
        "airData": "49",
        "airQuality": "优",
        "dateLong": 1654876800000,
        "weatherType": 1,
        "windLevel": 3,
        "province": "上海",
        "moreData": {
          "sunrise": "2022-06-11 04:49:00",
          "sunset": "2022-06-11 18:58:00",
          "precipitation": null,
          "alert": null
        }
      },
      {
        "city": "上海",
        "lastUpdateTime": "2022-06-08 16:09:00",
        "date": "2022-06-12",
        "weather": "小雨",
        "humidity": "未知",
        "wind": "东南风",
        "pm25": 0.0,
        "low": 20.0,
        "high": 26.0,
        "airData": "52",
        "airQuality": "良",
        "dateLong": 1654963200000,
        "weatherType": 7,
        "windLevel": 3,
        "province": "上海",
        "moreData": {
          "sunrise": "2022-06-12 04:49:00",
          "sunset": "2022-06-12 18:58:00",
          "precipitation": null,
          "alert": null
        }
      },
      {
        "city": "上海",
        "lastUpdateTime": "2022-06-08 16:09:00",
        "date": "2022-06-13",
        "weather": "小雨",
        "humidity": "未知",
        "wind": "东风",
        "pm25": 0.0,
        "low": 20.0,
        "high": 27.0,
        "airData": "46",
        "airQuality": "优",
        "dateLong": 1655049600000,
        "weatherType": 7,
        "windLevel": 3,
        "province": "上海",
        "moreData": {
          "sunrise": "2022-06-13 04:49:00",
          "sunset": "2022-06-13 18:59:00",
          "precipitation": null,
          "alert": null
        }
      },
      {
        "city": "上海",
        "lastUpdateTime": "2022-06-08 16:09:00",
        "date": "2022-06-14",
        "weather": "阴",
        "humidity": "未知",
        "wind": "东南风",
        "pm25": 0.0,
        "low": 21.0,
        "high": 26.0,
        "airQuality": "未知",
        "dateLong": 1655136000000,
        "weatherType": 2,
        "windLevel": 4,
        "province": "上海",
        "moreData": {
          "sunrise": "2022-06-14 04:50:00",
          "sunset": "2022-06-14 18:59:00",
          "precipitation": null,
          "alert": null
        }
      }
    ],
    "logoUrl": "http://iflycar.hfdn.openstorage.cn/xfypicture/dev/logo/moji.png"
  }
}

以上即是两个免费的天气API介绍。第一个中华万年历的应该更稳定些,第二个是讯飞内置的语音查询天气API,不排除后续讯飞接口优化。

3.乐享天气APP

潇潇已经使用中华万年历API开发了一款天气APP,有兴趣的朋友可参看。
在CSDN的GitCode库:https://gitcode.net/qq_25269161/leweather

你可能感兴趣的:(Android,开发,android)