City Lookup

Platform: API iOS Android

City Lookup provides reverse geocoding, geolocation lookup services, supports multi-language, fuzzy search and other functions.

With the City Lookup, you can get the basic information of the city, including the Location ID of the city (you need this ID to get the weather), multilingual name, latitude and longitude, time zone, altitude, rank, administrative, etc.

In addition, GeoAPI - City Lookup can also help you to implement fuzzy search in your APP, users only need to type 1 or 2 words to get results.

Request URL

https://geoapi.qweather.com/v2/city/lookup

Request Parameters

All parameters are separated by &. If no optional parameters are set, the default value will be used.

  • location(required)The location to be queried, support text, LocationID, comma-separated longitude and latitude (decimal, up to 2 decimal places), Adcode(Chinese cities only). For example: location=beijing or location=116.41,39.92

Fuzzy search, when the location passed as text, fuzzy search is supported, users can only enter a part of the city name to search, at least one Chinese character or 2 characters, and the results are sorted by correlation and Rank. It is easy for developers or users to choose which city they need to see the weather. For example, location=bei will return some of the most relevant results to bei, including Beirut in Lebanon and Beijing in China

Duplicate name, when the location is passed as text, cities with the same name may appear, such as Xi’an in Shaanxi Province, Xi’an District under Liaoyuan City in Jilin Province, and Xi’an District under Mudanjiang City in Heilongjiang Province. At this time, all results will be returned according to the Rank. In this case, you can use the adm parameter to further determine the city or region that needs to be queried, for example, location=Xi’an&adm=Heilongjiang

  • admSuperior administrative divisions of a city, useful for excluding cities with similar names or for filtering results. Example adm = beijing

If with adm, like location=chaoyang&adm=beijing, the returned results only include Chaoyang District in Beijing, not Chaoyang City in Liaoning Province

If without adm, like location=chaoyang, the returned results include Chaoyang District in Beijing, Chaoyang City in Liaoning Province, and Chaoyang District in Changchun City

  • 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.

Request Example

curl -X GET --compressed \
-H 'Authorization: Bearer your_token' \
'https://geoapi.qweather.com/v2/city/lookup?location=beij'

Replace your_token with your JWT or learn more about Authentication

Response

The response is in JSON format and is Gzip compressed.

{
  "code":"200",
  "location":[
    {
      "name":"北京",
      "id":"101010100",
      "lat":"39.90499",
      "lon":"116.40529",
      "adm2":"北京",
      "adm1":"北京市",
      "country":"中国",
      "tz":"Asia/Shanghai",
      "utcOffset":"+08:00",
      "isDst":"0",
      "type":"city",
      "rank":"10",
      "fxLink":"https://www.qweather.com/weather/beijing-101010100.html"
    },
    {
      "name":"海淀",
      "id":"101010200",
      "lat":"39.95607",
      "lon":"116.31032",
      "adm2":"北京",
      "adm1":"北京市",
      "country":"中国",
      "tz":"Asia/Shanghai",
      "utcOffset":"+08:00",
      "isDst":"0",
      "type":"city",
      "rank":"15",
      "fxLink":"https://www.qweather.com/weather/haidian-101010200.html"
    },
    {
      "name":"朝阳",
      "id":"101010300",
      "lat":"39.92149",
      "lon":"116.48641",
      "adm2":"北京",
      "adm1":"北京市",
      "country":"中国",
      "tz":"Asia/Shanghai",
      "utcOffset":"+08:00",
      "isDst":"0",
      "type":"city",
      "rank":"15",
      "fxLink":"https://www.qweather.com/weather/chaoyang-101010300.html"
    },
    {
      "name":"昌平",
      "id":"101010700",
      "lat":"40.21809",
      "lon":"116.23591",
      "adm2":"北京",
      "adm1":"北京市",
      "country":"中国",
      "tz":"Asia/Shanghai",
      "utcOffset":"+08:00",
      "isDst":"0",
      "type":"city",
      "rank":"23",
      "fxLink":"https://www.qweather.com/weather/changping-101010700.html"
    },
    {
      "name":"房山",
      "id":"101011200",
      "lat":"39.73554",
      "lon":"116.13916",
      "adm2":"北京",
      "adm1":"北京市",
      "country":"中国",
      "tz":"Asia/Shanghai",
      "utcOffset":"+08:00",
      "isDst":"0",
      "type":"city",
      "rank":"23",
      "fxLink":"https://www.qweather.com/weather/fangshan-101011200.html"
    },
    {
      "name":"通州",
      "id":"101010600",
      "lat":"39.90249",
      "lon":"116.65860",
      "adm2":"北京",
      "adm1":"北京市",
      "country":"中国",
      "tz":"Asia/Shanghai",
      "utcOffset":"+08:00",
      "isDst":"0",
      "type":"city",
      "rank":"23",
      "fxLink":"https://www.qweather.com/weather/tongzhou-101010600.html"
    },
    {
      "name":"丰台",
      "id":"101010900",
      "lat":"39.86364",
      "lon":"116.28696",
      "adm2":"北京",
      "adm1":"北京市",
      "country":"中国",
      "tz":"Asia/Shanghai",
      "utcOffset":"+08:00",
      "isDst":"0",
      "type":"city",
      "rank":"25",
      "fxLink":"https://www.qweather.com/weather/fengtai-101010900.html"
    },
    {
      "name":"大兴",
      "id":"101011100",
      "lat":"39.72891",
      "lon":"116.33804",
      "adm2":"北京",
      "adm1":"北京市",
      "country":"中国",
      "tz":"Asia/Shanghai",
      "utcOffset":"+08:00",
      "isDst":"0",
      "type":"city",
      "rank":"25",
      "fxLink":"https://www.qweather.com/weather/daxing-101011100.html"
    },
    {
      "name":"延庆",
      "id":"101010800",
      "lat":"40.46532",
      "lon":"115.98501",
      "adm2":"北京",
      "adm1":"北京市",
      "country":"中国",
      "tz":"Asia/Shanghai",
      "utcOffset":"+08:00",
      "isDst":"0",
      "type":"city",
      "rank":"33",
      "fxLink":"https://www.qweather.com/weather/yanqing-101010800.html"
    },
    {
      "name":"平谷",
      "id":"101011500",
      "lat":"40.14478",
      "lon":"117.11234",
      "adm2":"北京",
      "adm1":"北京市",
      "country":"中国",
      "tz":"Asia/Shanghai",
      "utcOffset":"+08:00",
      "isDst":"0",
      "type":"city",
      "rank":"33",
      "fxLink":"https://www.qweather.com/weather/pinggu-101011500.html"
    }
  ],
  "refer":{
    "sources":[
      "QWeather"
    ],
    "license":[
      "QWeather Developers License"
    ]
  }
}
  • code See Status Code
  • location.name Location Name
  • location.id Location ID
  • location.lat Latitude of the location
  • location.lon Longitude of the location
  • location.adm2 Name of the superior administrative division of the location
  • location.adm1 The first-level administrative area of ​​the location
  • location.country Country name of the location
  • location.tz Location timezone
  • location.utcOffset The number of hours offset between local time and UTC time, refer to UTC Offset
  • location.isDst Is the location currently on daylight saving time. 1 for daylight saving time and 0 for not in daylight saving time
  • location.type Location type
  • location.rank Location Rank
  • location.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