GeoDB Cities

FREEMIUM
By wirefreethought
Updated 3 months ago
Data
9.6/10
Popularity Score
128ms
Latency
100%
Success Rate
simon.mercier59a month ago
Advanced requestHello, I would like to do this search : Find cities : - near my location AND - in my country AND - sort them by distance It seems that it is NOT possible to - add the parameters "countryIds" and "location" in the same request - sort by distance Am I right ? Would it be possible to add this search criteria ? Thanks
wirefreethoughta month ago
Hmmm. Why can't you just do a single request without the country filters, then filter by country on the client side once you get the results? That should be more efficient I would think.
simon.mercier59a month ago
Thanks, I will try it and let you know. My need is to do an autocomplete search view like google maps... I am trying to do a smart algorithm. Currently I am doing 2 requests : - find cities in a radius -> exclude the one which are not in the user's country + sort them by distance (because the radius is large) - find cities in all the world and sort them by population Then I reorder them according to the user's query. I am assuming that the city the user is searching for should be in the first request. The second request is here in case of the user search for a city in a foreign country. It is far to be as efficient as google maps but the results are quite correct.
wirefreethoughta month ago
This has been deployed! New params, countryIds and excludedCountryIds, now available for this endpoint. Try it out.
wirefreethoughta month ago
My thinking at the time was that users looking to sort cities by distance from a location probably wouldn't care which country those cities were in, Guess I was wrong :) I will add this in the coming days and let you know.
Hi Developer, feel free to post your answer:

Install SDK for NodeJS

Installing

To utilize unirest for node.js install the the npm module:

$ npm install unirest

After installing the npm package you can now start simplifying requests like so:

var unirest = require('unirest');

Creating Request

unirest.get("https://wft-geo-db.p.rapidapi.com/v1/locale/locales")
.header("X-RapidAPI-Host", "wft-geo-db.p.rapidapi.com")
.header("X-RapidAPI-Key", "SIGN-UP-FOR-KEY")
.end(function (result) {
  console.log(result.status, result.headers, result.body);
});
OAuth2 Authentication
Client ID
Client Secret
OAuth2 Authentication