太阳和月亮

获取最近60天全球城市日出日落、月升月落和逐小时的月相数据。

逐天预报API中,也会返回对应天数的日出日落、月升月落和月相数据

请求URL

日出日落、月升月落和月相 HTTP GET

  • 商业版 https://api.qweather.com/v7/astronomy/sunmoon?{请求参数}
  • 开发版 https://devapi.qweather.com/v7/astronomy/sunmoon?{请求参数}

请求参数

请求参数包括必选和可选参数,如不填写可选参数将使用其默认值,参数之间使用&进行分隔。

location 必选

太阳高度角是基于经纬度测量的,需要填写具体的坐标,填写格式:经度,纬度(经度在前纬度在后,英文,分隔,十进制格式,北纬东经为正,南纬西经为负)。例如:location=116.41,39.92

key 必选

用户认证key,请参考如何获取你的KEY。支持数字签名方式进行认证。例如 key=123456789ABC

date 必选

选择日期,最多可选择最近60天的数据。日期格式为yyyyMMdd,例如 date=20200531

gzip 可选

对API接口进行压缩,可以极大的减少API接口访问延迟,减少缓存空间,提高接口连接成功率。默认开启gzip

  • y 使用gzip方式压缩,默认
  • n 不使用压缩

lang 可选

多语言,默认中文,例如lang=en。具体的语言参数值请参考多语言参数。当一些城市不存在对应的语言时,将返回英文或其本地语言结果。

返回数据

参数 描述 示例值
code API状态码,具体含义请参考状态码 200
updateTime 当前API的最近更新时间 2013-12-30T01:45+08:00
fxLink 该城市的太阳和月亮自适应网页,可嵌入网站或应用 http://hfx.link/ae45
sunrise 日出时间 2013-12-30T05:44+08:00
sunset 日落时间 2013-12-30T17:02+08:00
moonrise 月升时间 2013-12-30T13:19+08:00
moonset 月落时间 2013-12-31T23:31+08:00
moonPhase.fxTime 月相逐小时预报时间 2013-12-31T23:31+08:00
moonPhase.value 月相数值 0.25
moonPhase.name 月相名字 上弦月
moonPhase.illumination 月亮照明度,百分比数值 30
refer.sources 原始数据来源,可能为空  
refer.license 数据许可证  

请求和返回示例

日出日落、月升月落和月相

// 北京日出日落、月升月落和月相 
// 商业版 https://api.qweather.com/v7/astronomy/sunmoon?location=101010100&date=20200610&key=xxx
// 开发版 https://devapi.qweather.com/v7/astronomy/sunmoon?location=101010100&date=20200610&key=xxx
// 请将示例请求URL中的KEY更换成你自己的KEY,date更换为当天或未来60天任意日期

{
  "code": "200",
  "updateTime": "2020-06-14T16:57+08:00",
  "fxLink": "https://www.qweather.com/weather/beijing-101010100.html",
  "daily": [
    {
      "fxDate": "2020-06-14",
      "sunrise": "04:45",
      "sunset": "19:44",
      "moonrise": "01:05",
      "moonset": "12:53",
      "tempMax": "35",
      "tempMin": "22",
      "iconDay": "100",
      "textDay": "晴",
      "iconNight": "150",
      "textNight": "晴",
      "wind360Day": "358",
      "windDirDay": "北风",
      "windScaleDay": "1-2",
      "windSpeedDay": "8",
      "wind360Night": "234",
      "windDirNight": "西南风",
      "windScaleNight": "1-2",
      "windSpeedNight": "6",
      "humidity": "22",
      "precip": "0.0",
      "pressure": "1001",
      "vis": "25",
      "uvIndex": "11"
    },
    {
      "fxDate": "2020-06-15",
      "sunrise": "04:45",
      "sunset": "19:45",
      "moonrise": "01:29",
      "moonset": "13:51",
      "tempMax": "36",
      "tempMin": "22",
      "iconDay": "100",
      "textDay": "晴",
      "iconNight": "150",
      "textNight": "晴",
      "wind360Day": "6",
      "windDirDay": "北风",
      "windScaleDay": "1-2",
      "windSpeedDay": "2",
      "wind360Night": "220",
      "windDirNight": "西南风",
      "windScaleNight": "1-2",
      "windSpeedNight": "5",
      "humidity": "30",
      "precip": "0.0",
      "pressure": "999",
      "vis": "25",
      "uvIndex": "11"
    },
    {
      "fxDate": "2020-06-16",
      "sunrise": "04:45",
      "sunset": "19:45",
      "moonrise": "01:52",
      "moonset": "14:49",
      "tempMax": "35",
      "tempMin": "24",
      "iconDay": "100",
      "textDay": "晴",
      "iconNight": "150",
      "textNight": "晴",
      "wind360Day": "235",
      "windDirDay": "西南风",
      "windScaleDay": "3-4",
      "windSpeedDay": "18",
      "wind360Night": "206",
      "windDirNight": "西南风",
      "windScaleNight": "1-2",
      "windSpeedNight": "5",
      "humidity": "30",
      "precip": "0.0",
      "pressure": "994",
      "vis": "25",
      "uvIndex": "11"
    }
  ],
  "refer": {
    "sources": [
      "Weather China"
    ],
    "license": [
      "commercial license"
    ]
  }
}