Using the API for dropdown lists
If you're looking to get advanced data on a country, state or city then you'll want to check out the API Demo to learn the URIs required to get rich responses.
To use Geodata Solutions for dynamic dropdowns lists, the easiest way is to use our simple code snippet that can have to set up in minutes. However, if you're looking for a web service just for dropdown lists and our code snippet doesn't fit your requirements, or you have any other implementation where you just need the name of the location, then read on.
1. QUERYING THE API
The /restapi URI
You'll need to start by sending all of your queries to the https://geodata.solutions/restapi/ uri
The dd parameter
In order to tell the API that you're just wanting the names of locations, you MUST include a ?dd= parameter
- To limit the results by minimum population, use a 'pop' designator
- pop10k - limits results to place with 10,000 people or more
- pop100k - limits results to place with 100,000 people or more
- pop1m - limits results to place with 1,000,000 people or more
- pop10m - limits results to place with 10,000,000 people or more
- To order the results by population, add ordpop
- If you don't want any filtering or ordering, just add ?dd=1
nb. You can separate dd params by a dash, so to limit to places over 100,000 people and return the results in order of population, you can put ?dd=pop100k-ordpop
Click to view the results
https://geodata.solutions/restapi?dd=1
https://geodata.solutions/restapi?dd=pop1m-ordpop
2. FETCHING STATES & CITIES
To get the states for a country, you just need to add a &country parameter with the code contained as the key in the country and state arrays
https://geodata.solutions/restapi?dd=1&country=IN
https://geodata.solutions/restapi?dd=pop10k-ordpop&country=AU&state=NSW
3. USING THIS IN A FORM
You can use this in a form by adding javascript functions to onload and onchange events. More details to come soon.