Weather Hourly Forecast

Platform: API iOS Android

Get hourly weather forecasts for cities around the world for the next 24-168 hours.

Interface code Interface Class
weather24h 24-hours forecast WeatherHourlyResponse
weather72h 72-hours forecast WeatherHourlyResponse
weather168h 168-hours forecast WeatherHourlyResponse

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=101010100 or location=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 are unit=m for metric(default) and unit=i for imperial. See more about Unit.

Sample code

Swift

Task{
    do {
        let parameter = WeatherParameter(location: "101010100")
        /**
        * 24-hours forecast
        */
        let _ = try await QWeather.instance
            .weather24h(parameter)

        /**
        * 72-hours forecast
        */
        let _ = try await QWeather.instance
            .weather72h(parameter)
        
        /**
        * 168-hours forecast
        */
        let _ = try await QWeather.instance
            .weather168h(parameter)

    } catch QWeatherError.errorResponse(let error) {
        print(error)
    } catch {
        print(error)
    }
}

Objective-C

    WeatherParameter * parameter = [WeatherParameter instanceWithLocation:@"101010100" lang:@(LangZH_HANS) unit:@(UnitMETRIC)];

    void (^handler)(WeatherHourlyResponse *, NSError *) = ^(WeatherHourlyResponse *response,
    NSError *error) {
        if (response) {
            NSLog(@"%@", response.description);
        }
        if (error) {
            NSLog(@"%@", error.localizedDescription);
        }
    };

    /**
    * 24-hour forecast data
    */
    [QWeatherObjc weather24h:parameter completionHandler:handler];

    /**
    * 72-hour forecast data
    */
    [QWeatherObjc weather72h:parameter completionHandler:handler];

    /**
    * 168-hour forecast data
    */
    [QWeatherObjc weather168h:parameter completionHandler:handler];

Response

WeatherHourlyResponse

  • code See Status Code
  • updateTime API last update time
  • fxLink Responsive web page of this data, for embedded in website or APP
  • hourly.fxTime Forecast time
  • hourly.temp temperature
  • hourly.icon Icon code for weather conditions. See also QWeather Icons
  • hourly.text Weather conditions
  • hourly.wind360 Wind direction in azimuth degree
  • hourly.windDir Wind direction
  • hourly.windScale Wind scale
  • hourly.windSpeed Wind speed, KM/H
  • hourly.humidity Relative humidity in percent
  • hourly.precip Accumulated precipitation in the current hour
  • hourly.pop Precipitation probability in percent, may be null
  • hourly.pressure Atmospheric pressure, hPa
  • hourly.cloud Cloud cover in percent, may be null
  • hourly.dew Dew point temperature, may be null
  • refer.sources Data source and other statements, may be null
  • refer.license Data license, may be null