Skip to content

A small API to send search queries to a geoname database.

License

Notifications You must be signed in to change notification settings

benmaier/geonameapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

geonameapi

A small webserver that searches for populated places on earth by sending requests to a geoname database.

example

Prerequisites

First, you need to copy the geoname database to your own mysql-server. Clone this adapted GeonameSQL-Importer and follow the instructions therein.

Afterwards, add a config-file containing information about the database to your home directory. It must have the path

~/.geonames/db.json

and a structure equivalent to

{
    "host": "serveraddress",
    "port": 3306,
    "user": "your_user",
    "passwd": "your_password_string",
    "dbname": "geonames"
}

Install

Activate the environment first

source env/bin/activate

Then run

pip install -r requirements.text

Run

Activate the environment first

source env/bin/activate

Then run the app

FLASK_APP=apigeoname.py flask run

Usage

Use either the small interface in localhost:5000/ or send custom requests to

    localhost:5000/api/searchplaces?string=YourSearchString

or

    localhost:5000/api/searchcountryregioncontinent?string=YourSearchString

You'll get a json response encoded in utf8.

The entries in a /searchplaces-request are ordered as

[
   geonameid,
   name,
   countrycode, #(2 characters, iso)
   countryname,
   featurecode,
   featurename,
   featuredescription,
   population,
   alternatename
]

For a /searchcountryregioncontinent-request, the response is ordered as

[
   geonameid,
   name,
   countrycode, #(2 characters, iso)
   countryname,
   featurecode,
   population,
   alternatename
]

Note that a single geonameid will appear multiple times with different alternatenames. These are ordered after [ISO_LANGUAGE, "en", ""] where ISO_LANGUAGE refers to the corresponding property Config.ISO_LANGUAGE in /config.py.

About

A small API to send search queries to a geoname database.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published