GeoAPI

For iOS SDK v4.4+

Weather data is based on geographic location, so you need to know specific location information before getting the weather. QWeather provides a powerful GeoAPI service, which can obtain the basic information of the city that needs to be queried, including the location ID of the city or region (you need this ID to query the weather), multilingual name, latitude and longitude, time zone, altitude, Rank value, administrative division, etc.

In addition, the GeoAPI service can also help you:

  • Avoid the trouble of the same name city
  • Return multiple city results based on the name entered by the user in your APP or website, so that the user can select an accurate city and return the city’s weather
  • Display popular cities in your APP or website, users can directly select, reduce search steps and improve user experience
  • No need to maintain the city list, city information updates are obtained in real time

GeoAPI is free for the first 50,000 calls per day for each account, more calls refer to price

City Lookup

Interface code (Enum) Interface Class
INQUIRE_TYPE_GEO_CITY_LOOKUP City lookup GeoBaseClass

Request Parameters

If no optional parameters are set, the default value will be used.

appKey

API authentication key, please refer to How To Get Your Key.

For example: appKey=12334567890ABC

location

The location to be queried, support text, LocationID, comma-separated longitude and latitude, Adcode(Chinese cities only).

For example: location=beijing or location=116.41,39.92

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

range

Set to search only within a certain country. The country name needs to use country code ISO 3166.

  • world Around the world, default
  • cn China
  • us United States
  • fr France
  • uk United Kingdom
  • ru Russia
  • See more country code
number

Number of the results in response, from 1 to 20, 10 is the default

Sample Code

    QWeatherConfigInstance.publicID = @"publicID";
    QWeatherConfigInstance.appKey = @"key";
    QWeatherConfigInstance.appType = APP_TYPE_BIZ;
    QWeatherConfigInstance.location = @"beijing";
    [QWeatherConfigInstance weatherWithInquireType:INQUIRE_TYPE_GEO_CITY_LOOKUP WithSuccess:^(GeoBaseClass *responseObject) {
        
        NSLog(@"Description->%@",[responseObject description]);
        
    } faileureForError:^(NSError *error) {
        NSLog(@"error->%@",error);
        
    }];

Response

Parameters Description Example
code Status code, please refer to Status Code 200
location.name Location Name Nanshan District
location.cid Location ID 101280604
location.lat Location latitude 22.53122
location.lon Location longitude 113.92942
location.adm2 Name of the superior administrative division of the location Shenzhen
location.adm1 The first-level administrative region of the location Guangdong Province
location.country Country name of the location China
location.tz Timezone of the location +0800
location.utcOffset The number of hours offset between local time and UTC time, refer to UTC-Offset +08:00
location.isDst Is the location currently observing Daylight Saving time
1 in daylight saving time
0 not in daylight saving time
0
location.type Type of the location city
location.rank Location Rank 10
location.fxLink Responsive web page of this location, easy to embed in your website or APP http://hfx.link/34T5
refer.sources Data source and other statements, may be null  
refer.license License, may be null  

Top City

Interface code (Enum) Interface Class
  INQUIRE_TYPE_GEO_TOPCITY Top city GeoBaseClass

Request Parameters

If no optional parameters are set, the default value will be used.

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

range

Set to search only within a certain country. The country name needs to use country code ISO 3166.

  • world Around the world, default
  • cn China
  • us United States
  • fr France
  • uk United Kingdom
  • ru Russia
  • See more country code
number

Number of the results in response, from 1 to 20, 10 is the default

Sample Code


    QWeatherConfigInstance.publicID = @"publicID";
    QWeatherConfigInstance.appKey = @"key";
    QWeatherConfigInstance.appType = APP_TYPE_BIZ;
    QWeatherConfigInstance.location = @"beijing";
    [QWeatherConfigInstance weatherWithInquireType:INQUIRE_TYPE_GEO_TOPCITY WithSuccess:^(GeoBaseClass *responseObject) {
        
        NSLog(@"Description->%@",[responseObject description]);
        
    } faileureForError:^(NSError *error) {
        NSLog(@"error->%@",error);
        
    }];

Response

Parameters Description Example
code Status code, please refer to Status Code 200
location.name Location Name Nanshan District
location.cid Location ID 101280604
location.lat Latitude of the location 22.53122
location.lon Longitude of the location 113.92942
location.adm2 Name of the superior administrative division of the location Shenzhen
location.adm1 The first-level administrative region of the location Guangdong Province
location.country Country name of the location China
location.tz Location Timezone +0800
location.utcOffset The number of hours offset between local time and UTC time, refer to UTC-Offset +08:00
location.isDst Is the location currently observing Daylight Saving time
1 in daylight saving time
0 not in daylight saving time
0
location.type Location type city
location.rank Location Rank 10
location.fxLink Responsive web page of this location, easy to embed in your website or APP http://hfx.link/34T5
refer.sources Data source and other statements, may be null  
refer.license License, may be null  

POI Lookup

Interface code (Enum) Interface Class
INQUIRE_TYPE_GEO_POI_LOOKUP POI Lookup GeoBaseClass

Request Parameters

If no optional parameters are set, the default value will be used.

location

The location to be queried, support text, LocationID, comma-separated longitude and latitude, Adcode(Chinese cities only).

For example: location=beijing or location=116.41,39.92

appKey

API authentication key, please refer to How To Get Your Key.

For example: appKey=12334567890ABC

type

Choose to search for a certain type of POI.

  • scenic Scenic Spot
  • CSTA Currents Station
  • TSTA Tide Station
city

Search for POI within a given city. The city name can be text or the city’s LocationID.

The city name is an exact match. It is recommended to use LocaitonID. If the text cannot be matched, the data returned will be empty.

number

Number of the results in response, from 1 to 20, 10 is the default

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 = @"beijing";
    [QWeatherConfigInstance weatherWithInquireType:INQUIRE_TYPE_GEO_POI_LOOKUP WithSuccess:^(GeoBaseClass *responseObject) {
        
        NSLog(@"Description->%@",[responseObject description]);
        
    } faileureForError:^(NSError *error) {
        NSLog(@"error->%@",error);
        
    }];

Response

Parameters Description Example
code Status code, please refer to Status Code 200
location.name Location Name Nanshan District
location.cid Location ID 101280604
location.lat Latitude of the location 22.53122
location.lon Longitude of the location 113.92942
location.adm2 Name of the superior administrative division of the location Shenzhen
location.adm1 The first-level administrative region of the location Guangdong Province
location.country Country name of the location China
location.tz Location Timezone +0800
location.utcOffset The number of hours offset between local time and UTC time, refer to UTC-Offset +08:00
location.isDst Is the location currently observing Daylight Saving time
1 in daylight saving time
0 not in daylight saving time
0
location.type POI type scenic
location.rank Location Rank 10
location.fxLink Responsive web page of this location, easy to embed in your website or APP http://hfx.link/34T5
refer.sources Data source and other statements, may be null  
refer.license License, may be null  

POI Range

Interface code (Enum) Interface Class
INQUIRE_TYPE_GEO_POI_RANGE POI range GeoBaseClass

Request Parameters

If no optional parameters are set, the default value will be used.

location

The comma-separated longitude and latitude of the location to be queried.

For example: location=116.41,39.92

appKey

API authentication key, please refer to How To Get Your Key.

For example: appKey=12334567890ABC

radius

Set search radius, the value range is 1-50, in kilometers. 5 by default.

number

Number of the results in response, from 1 to 20, 10 is the default

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 = @"116.4,39.1";
    [QWeatherConfigInstance weatherWithInquireType:INQUIRE_TYPE_GEO_POI_RANGE WithSuccess:^(GeoBaseClass *responseObject) {
        
        NSLog(@"Description->%@",[responseObject description]);
        
    } faileureForError:^(NSError *error) {
        NSLog(@"error->%@",error);
        
    }];
    

Response

Parameters Description Example
code Status code, please refer to Status Code 200
location.name Location Name Nanshan District
location.cid Location ID 101280604
location.lat Latitude of the location 22.53122
location.lon Longitude of the location 113.92942
location.adm2 Name of the superior administrative division of the location Shenzhen
location.adm1 The first-level administrative region of the location Guangdong Province
location.country Country name of the location China
location.tz POI Timezone +0800
location.utcOffset The number of hours offset between local time and UTC time, refer to UTC-Offset +08:00
location.isDst Is the location currently observing Daylight Saving time
1 in daylight saving time
0 not in daylight saving time
0
location.type POI type city
location.rank Location Rank 10
location.fxLink Responsive web page of this location, easy to embed in your website or APP http://hfx.link/34T5
refer.sources Data source and other statements, may be null  
refer.license License, may be null