Sun and Moon
For iOS SDK v4.9+Get the latest 60-day global city sunrise/sunset, moon rise/moon set, moon phase and and solar elevation angle data.
Sunrise and Sunset
Get the last 60 days of sunrise and sunset data for cities around the world.
Interface code (Enum) | Interface | Class |
---|---|---|
INQUIRE_TYPE_ASTRONOMY_SUN | Sunrise and sunset data | SunBaseModel |
Request Parameters
If no optional parameters are set, the default value will be used.
location
The city to be queried, support LocationID or comma-separated longitude and latitude (decimal, up to 2 decimal places), LocationID can be obtained by GeoAPI.
date
Set the date, up to 60 days in the future (including today). The date format is yyyyMMdd
For example: date=20200531
appKey
API authentication key, please refer to How To Get Your Key.
For example: appKey=12334567890ABC
Sample Code
QWeatherConfigInstance.publicID = @"publicID";
QWeatherConfigInstance.appKey = @"key";
QWeatherConfigInstance.appType = APP_TYPE_BIZ;
QWeatherConfigInstance.location = @"101010100";
QWeatherConfigInstance.date = @"20200425";
[QWeatherConfigInstance weatherWithInquireType:INQUIRE_TYPE_ASTRONOMY_SUN WithSuccess:^(SunBaseModel *responseObject) {
NSLog(@"描述->%@",[responseObject description]);
} faileureForError:^(NSError *error) {
NSLog(@"error->%@",error);
}];
Response
Parameters | Description |
---|---|
code |
API status code, please refer to Status Code |
updateTime |
|
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 |
Moon
Get the last 60 days of moonrise, moonset and moon phase data for cities around the world.
Interface code (Enum) | Interface | Class |
---|---|---|
INQUIRE_TYPE_ASTRONOMY_MOON | Moonrise, moonset and moon phase data | MoonBaseModel |
Request Parameters
If no optional parameters are set, the default value will be used.
location
The city to be queried, support LocationID or comma-separated longitude and latitude (decimal, up to 2 decimal places), LocationID can be obtained by GeoAPI.
date
Set the date, up to 60 days in the future (including today). The date format is yyyyMMdd
For example: date=20200531
appKey
API authentication key, please refer to How To Get Your Key.
For example: appKey=12334567890ABC
lang
Multi-language, default Chinese, if data does not match the language you set, it will return in English or its native language. Language parameter please refer to Language
Sample Code
QWeatherConfigInstance.publicID = @"publicID";
QWeatherConfigInstance.appKey = @"key";
QWeatherConfigInstance.appType = APP_TYPE_BIZ;
QWeatherConfigInstance.location = @"101010100";
QWeatherConfigInstance.date = @"20200425";
[QWeatherConfigInstance weatherWithInquireType: INQUIRE_TYPE_ASTRONOMY_MOON WithSuccess:^(MoonBaseModel *responseObject) {
NSLog(@"描述->%@",[responseObject description]);
} faileureForError:^(NSError *error) {
NSLog(@"error->%@",error);
}];
Response
Parameters | Description |
---|---|
code |
API status code, please refer to Status Code |
updateTime |
|
fxLink |
Responsive web page of this data, for embedded in website or APP |
moonrise |
Moonrise time |
moonset |
Moonrise time |
moonPhase.fxTime |
Moon phase forecast time |
moonPhase.value |
Moon phase value |
moonPhase.name |
Moon Phase Name |
moonPhase.icon |
Icon code for moon phase, free to download QWeather Icons |
moonPhase.illumination |
Moon illuminance in percent |
refer.sources |
Data source and other statements, may be null |
refer.license |
Data license, may be null |
Solar Elevation Angle
Get global solar elevation angle and azimuth.
Interface code (Enum) | Interface | Class |
---|---|---|
INQUIRE_TYPE_ASTRONOMY_SUN_ANGLE | Solar elevation angle data | SunAngleBaseModel |
Request Parameters
If no optional parameters are set, the default value will be used.
location
The comma-separated longitude and latitude (decimal, up to 2 decimal places) of the location to be queried.
For example: location=116.41,39.92
date
Set date, format is yyyyMMdd, e.g., date=20200531
time
Set time, format is HHmm, 24-hour, e.g., time=1230
tz
Location time zone, e.g., tz=0800
or tz=-0530
alt
Location altitude, in meters, e.g., alt=43
appKey
API authentication key, please refer to How To Get Your Key.
For example: appKey=12334567890ABC
Sample Code
QWeatherConfigInstance.publicID = @"publicID";
QWeatherConfigInstance.appKey = @"key";
QWeatherConfigInstance.appType = APP_TYPE_BIZ;
QWeatherConfigInstance.location = @"116.41,39.92";
QWeatherConfigInstance.date = @"20210518";
QWeatherConfigInstance.time = @"1230";
QWeatherConfigInstance.tz = @"0800";
QWeatherConfigInstance.alt = @"43";
[QWeatherConfigInstance weatherWithInquireType:INQUIRE_TYPE_ASTRONOMY_SUN_ANGLE WithSuccess:^(SunAngleBaseModel *responseObject) {
NSLog(@"描述->%@",[responseObject description]);
} faileureForError:^(NSError *error) {
NSLog(@"error->%@",error);
}];
Response
Parameters | Description |
---|---|
code |
API status code, please refer to Status Code |
solarElevationAngle |
Solar Elevation Angle in degree |
solarAzimuthAngle |
Solar azimuth angle |
solarHour |
Solar time, HHmm format |
hourAngle |
Hour Angle |
refer.sources |
Data source and other statements, may be null |
refer.license |
Data license, may be null |