Sunrise and Sunset

Platform: API iOS Android

Get the sunrise and sunset times for the next 60 days at any location worldwide.

Request URL

https://api.qweather.com/v7/astronomy/sun

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.

  • 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 or location=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

Request Example

curl -X GET --compressed \
-H 'Authorization: Bearer your_token' \
'https://api.qweather.com/v7/astronomy/sun?location=101010100&date=20210220'

Replace your_token with your JWT or learn more about Authentication

Response

The response is in JSON format and is Gzip compressed.

{
  "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