Real-time Weather
Get real-time weather data for 200,000+ cities around the world, including temperature, wind, humidity, pressure, precipitation, visibility, etc.
| Interface code | Interface | Class |
|---|---|---|
| weatherNow | Real-time weather | WeatherNowResponse |
Parameters
WeatherParameter
-
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 -
langMulti-language setting, please see Language to find out how our multi-language works and how to set up. -
unitSet weather data unit, the available value areunit=mfor metric(default) andunit=ifor imperial. See more about Unit.
Sample code
Swift
Task{
do {
let parameter = WeatherParameter(location: "101010100")
let response = try await QWeather.instance
.weatherNow(parameter)
print(response)
} catch QWeatherError.errorResponse(let error) {
print(error)
} catch {
print(error)
}
}
Objective-C
WeatherParameter * parameter = [WeatherParameter instanceWithLocation:@"101010100" lang:@(LangZH_HANS) unit:@(UnitMETRIC)];
[QWeatherObjc weatherNow:parameter completionHandler:^(WeatherNowResponse * _Nullable response, NSError * _Nullable error) {
if (response) {
NSLog(@"%@", response.description);
}
if (error) {
NSLog(@"%@", error.localizedDescription);
}
}];
Response
WeatherNowResponse
-
codeSee Status Code -
updateTimeAPI last update time -
fxLinkResponsive web page of this data, for embedded in website or APP -
now.obsTimeObservation time -
now.temptemperature -
now.feelsLikeFeels like temperature -
now.iconIcon code for weather conditions. See also QWeather Icons -
now.textWeather conditions -
now.wind360Wind direction in azimuth degree -
now.windDirWind direction -
now.windScaleWind scale -
now.windSpeedWind speed, KM/H -
now.humidityRelative humidity in percent -
now.precipAccumulated precipitation in the last hour -
now.pressureAtmospheric pressure, hPa -
now.visVisibility, KM -
now.cloudCloud cover in percent, may be null -
now.dewDew point temperature, may be null -
refer.sourcesData source and other statements, may be null -
refer.licenseData license, may be null