Sunrise and Sunset

Get the sunrise and sunset times of global cities.

Request URL

  • Prohttps://api.qweather.com/v7/astronomy/sun?[params]

Request Parameters

All parameters are separated by &. If no optional parameters are set, the default value will be used.

key

API authentication key, please refer to How To Get Your Key. Support Signature Authentication.

For example: key=12334567890ABC

location

The location to be queried, support LocationID or comma-separated longitude and latitude, LocationID can be obtained by GeoAPI.

For example: location=101010100 or location=116.41,39.92

date

Set the date, up to 60 days in the future (including today). The date format is yyyyMMdd

For example: date=20200531

lang

Multi-language setting, if data does not match the language you set, it will return results in English or its native language.

Response

// New York sunrise and sunset on 2021-02-20
// Pro API https://api.qweather.com/v7/astronomy/sun?location=1E98E&date=20210220&lang=en&key=YOUR_KEY
// Replace date=20210220 with next 60 days

{
  "code": "200",
  "updateTime": "2021-02-16T22:00-05:00",
  "fxLink": "http://hfx.link/20ag1",
  "sunrise": "2021-02-20T06:40-05:00",
  "sunset": "2021-02-20T17:38-05:00",
  "refer": {
    "sources": [
      "qweather.com"
    ],
    "license": [
      "commercial license"
    ]
  }
}
Parameters Description
code

API status code, please refer to Status Code

updateTime

API last update time

fxLink

Responsive web page of this data, for embedded in website or APP

sunrise

Sunrise time

sunset

Sunrise time

refer.sources

Data source and other statements, may be null

refer.license

Data license, may be null