Sunrise and Sunset
Get the sunrise and sunset times for the next 60 days at any location worldwide.
Request URL
https://api.qweather.com/v7/astronomy/sun?[params]
For Free subscription, change the API Host to devapi.qweather.com
. See data available for Free subscription.
Request Parameters
All parameters are separated by &
. If no optional parameters are set, the default value will be used.
-
key
(required)API authentication key, please refer to How To Get Your Key. Support Signature Authentication. Example:key=12334567890ABC
-
location
(required)The location to be queried, support LocationID or comma-separated longitude and latitude (decimal, up to 2 decimal places), LocationID can be obtained by GeoAPI. Example:location=101010100
orlocation=116.41,39.92
-
date
(required)Set the date, up to 60 days in the future (including today). The date format is yyyyMMdd. Example:date=20200531
-
lang
Multi-language setting, see Language code for available value. If data does not match the language you set, it will return results in English or its native language.
Request Example
Sunrise and sunset on 2021-02-20 for Beijing, replace date=20210220
with next 60 days.
curl -L -X GET --compressed 'https://api.qweather.com/v7/astronomy/sun?location=101010100&date=20210220&key=YOUR_KEY'
Response
The response is in JSON format and is Gzip compressed, all fields are Strings.
{
"code": "200",
"updateTime": "2021-02-17T11:00+08:00",
"fxLink": "http://hfx.link/2ax1",
"sunrise": "2021-02-20T06:58+08:00",
"sunset": "2021-02-20T17:57+08:00",
"refer": {
"sources": [
"QWeather"
],
"license": [
"QWeather Developers License"
]
}
}
-
code
See Status Code -
updateTime
API last update time -
fxLink
Responsive web page of this data, for embedded in website or APP -
sunrise
Sunrise time. Maybe null in high latitude area -
sunset
Sunset time. Maybe null in high latitude area -
refer.sources
Data source and other statements, may be null -
refer.license
Data license, may be null