https://github.com/benmaier/geonameapi
A small API to send search queries to a geoname database.
https://github.com/benmaier/geonameapi
Last synced: 2 months ago
JSON representation
A small API to send search queries to a geoname database.
- Host: GitHub
- URL: https://github.com/benmaier/geonameapi
- Owner: benmaier
- License: other
- Created: 2019-09-13T17:38:13.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-09-23T22:29:36.000Z (over 2 years ago)
- Last Synced: 2024-10-11T11:08:15.298Z (8 months ago)
- Language: CSS
- Size: 1.28 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# geonameapi
A small webserver that searches for populated places on earth by sending requests to a geoname database.

## Prerequisites
First, you need to copy the geoname database to your own mysql-server. Clone this [adapted GeonameSQL-Importer](https://github.com/benmaier/GeoNames-MySQL-DataImport) 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
```json
{
"host": "serveraddress",
"port": 3306,
"user": "your_user",
"passwd": "your_password_string",
"dbname": "geonames"
}
```## Install
Activate the environment first
```bash
source env/bin/activate
```Then run
```bash
pip install -r requirements.text
```## Run
Activate the environment first
```bash
source env/bin/activate
```Then run the app
```bash
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
```python
[
geonameid,
name,
countrycode, #(2 characters, iso)
countryname,
featurecode,
featurename,
featuredescription,
population,
alternatename
]
```For a `/searchcountryregioncontinent`-request, the response is ordered as
```python
[
geonameid,
name,
countrycode, #(2 characters, iso)
countryname,
featurecode,
population,
alternatename
]
```Note that a single geonameid will appear multiple times with different `alternatename`s. These are ordered after `[ISO_LANGUAGE, "en", ""]` where `ISO_LANGUAGE` refers to the corresponding property `Config.ISO_LANGUAGE` in `/config.py`.