A FastAPI wrapper for the python-geonames library, providing RESTful API access to GeoNames data.
- Async API endpoints for GeoNames data
- Full OpenAPI documentation
- Input validation using Pydantic
- Easy deployment with Docker
- Comprehensive test coverage
- Clone the repository:
git clone https://github.com/yourusername/geonames-fastapi.git
cd geonames-fastapi- Install dependencies with Poetry:
poetry install- Create data directory:
mkdir geonames_data- Activate the virtual environment:
poetry shell- Run the development server:
uvicorn app.main:app --reloadThe API will be available at http://localhost:8000. API documentation is available at:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
Run tests with pytest:
pytestRun tests with coverage:
pytest --cov=app tests/GET /health- Health check endpointGET /stats- Get database statisticsGET /location/{country_code}/{postal_code}- Get location by country code and postal codeGET /search/name/{name}- Search locations by nameGET /search/coordinates?lat={lat}&lon={lon}&radius={radius}- Search locations by coordinatesGET /search/country/{country_code}- Search locations by country code
- Build the Docker image:
docker build -t geonames-fastapi .- Run the container:
docker run -d -p 8000:8000 geonames-fastapigeonames-fastapi/
├── app/
│ ├── __init__.py
│ ├── main.py
│ ├── models.py
│ └── dependencies.py
├── tests/
│ ├── __init__.py
│ ├── conftest.py
│ └── test_api.py
├── geonames_data/
├── Dockerfile
├── pyproject.toml
├── README.md
└── .gitignore
MIT License