Moon and Moon Phase
Get moonrise and moonset and hourly moon phase data for the next 60 days at any location worldwide.
| Interface code | Interface | Class |
|---|---|---|
| astronomyMoon | Moonrise, moonset and moon phase data | AstronomyMoonResponse |
Parameters
AstronomyMoonParameter
-
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=101010100orlocation=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 -
langMulti-language setting, please see Language to find out how our multi-language works and how to set up.
Sample code
Swift
Task {
do {
let formatter = DateFormatter()
formatter.dateFormat = "yyyMMdd"
let date = formatter.string(from: Date())
let parameter = AstronomyMoonParameter(location: "101010100", date: date)
let response = try await QWeather.instance
.astronomyMoon(parameter)
print(response)
} catch QWeatherError.errorResponse(let error) {
print(error)
} catch {
print(error)
}
}
Objective-C
NSDateFormatter * formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyyMMdd"];
NSString * date = [formatter stringFromDate:[NSDate date]];
AstronomyMoonParameter *parameter = [AstronomyMoonParameter instanceWithLocation:@"101010100" date:date lang:@(LangZH_HANS)];
[QWeatherObjc astronomyMoon:parameter completionHandler:^(AstronomyMoonResponse * _Nullable response, NSError * _Nullable error) {
if (response) {
NSLog(@"%@", response.description);
}
if (error) {
NSLog(@"%@", error.localizedDescription);
}
}];
Response
AstronomyMoonResponse
-
codeSee Status Code -
updateTimeAPI last update time -
fxLinkResponsive web page of this data, for embedded in website or APP -
moonriseMoonrise time of current day. Maybe null -
moonsetMoonset time of current day. Maybe null -
moonPhase.fxTimeMoon phase forecast time -
moonPhase.valueMoon phase value -
moonPhase.nameMoon phase name -
moonPhase.iconIcon code for moon phase. See also QWeather Icons -
moonPhase.illuminationMoon illuminance in percent -
refer.sourcesData source and other statements, may be null -
refer.licenseData license, may be null