City Lookup
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.
Endpoint
/geo/v2/city/lookup
Parameters
Query parameters
-
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=beijingorlocation=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=beiwill 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
admparameter 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. Exampleadm = beijing
If with
adm, likelocation=chaoyang&adm=beijing, the returned results only include Chaoyang District in Beijing, not Chaoyang City in Liaoning ProvinceIf without
adm, likelocation=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://your_api_host/geo/v2/city/lookup?location=beij'Replace your_token and your_api_host with your JWT Authentication and API Host
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"
]
}
}
-
codeSee Status Code -
location.nameLocation Name -
location.idLocation ID -
location.latLatitude of the location -
location.lonLongitude of the location -
location.adm2Name of the superior administrative division of the location -
location.adm1The first-level administrative area of the location -
location.countryCountry name of the location -
location.tzLocation timezone -
location.utcOffsetThe number of hours offset between local time and UTC time, refer to UTC Offset -
location.isDstIs the location currently on daylight saving time.1for daylight saving time and0for not in daylight saving time -
location.typeLocation type -
location.rankLocation Rank -
location.fxLinkResponsive web page of this location, easy to embed in your website or APP -
refer.sourcesData source and other statements, may be null -
refer.licenseData license, may be null