Top City

Platform: API iOS Android

Get a list of popular cities around the world.

Interface code Interface Class
geoCityTop Top city GeoCityTopResponse

Parameters

GeoCityTopParameter

  • rangeSet to search only within a certain country or region. The country and region name needs to use country code ISO 3166. If this parameter is not set, the search range will be all cities. Example: range=cn
  • numberNumber of the results in response, from 1 to 20, 10 is the default.
  • 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 response = try await QWeather.instance
            .geoCityTop(.init(range: Range.CN))
        print(response)
    } catch QWeatherError.errorResponse(let error) {
        print(error)
    } catch {
        print(error)
    }
}

Objective-C

GeoCityTopParameter *parameter = [GeoCityTopParameter instanceWithRange:@(RangeCN) number:@(10) lang:@(LangZH_HANS)];
[QWeatherObjc geoCityTop:parameter completionHandler:^(GeoCityTopResponse * _Nullable response, NSError * _Nullable error) {
    if (response) {
        NSLog(@"%@", response.description);
    }
    if (error) {
        NSLog(@"%@", error.localizedDescription);
    }
}];

Response

GeoCityTopResponse

  • code See Status Code
  • topCityList.name Location Name
  • topCityList.id Location ID
  • topCityList.lat Latitude of the location
  • topCityList.lon Longitude of the location
  • topCityList.adm2 Name of the superior administrative division of the location
  • topCityList.adm1 The first-level administrative area of ​​the location
  • topCityList.country Country name of the location
  • topCityList.tz Location timezone
  • topCityList.utcOffset The number of hours offset between local time and UTC time, refer to UTC Offset
  • topCityList.isDst Is the location currently on daylight saving time. 1 for daylight saving time and 0 for not in daylight saving time
  • topCityList.type Location type
  • topCityList.rank Location Rank
  • topCityList.fxLink Responsive web page of this location, easy to embed in your website or APP
  • refer.sources Data source and other statements, may be null
  • refer.license Data license, may be null