mirror of
https://github.com/Aareon/geonames-fastapi.git
synced 2026-11-10 07:03:07 -06:00
No description
- Python 96.2%
- Dockerfile 3.8%
| geonames_fastapi | ||
| .gitignore | ||
| Dockerfile | ||
| poetry.lock | ||
| pyproject.toml | ||
| README.md | ||
| run.py | ||
| setup.py | ||
GeoNames FastAPI
A FastAPI wrapper for the python-geonames library, providing RESTful API access to GeoNames data.
Features
- Async API endpoints for GeoNames data
- Full OpenAPI documentation
- Input validation using Pydantic
- Easy deployment with Docker
- Comprehensive test coverage
Installation
- 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
Development
- Activate the virtual environment:
poetry shell
- Run the development server:
uvicorn app.main:app --reload
The API will be available at http://localhost:8000. API documentation is available at:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
Testing
Run tests with pytest:
pytest
Run tests with coverage:
pytest --cov=app tests/
API Endpoints
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
Docker Deployment
- Build the Docker image:
docker build -t geonames-fastapi .
- Run the container:
docker run -d -p 8000:8000 geonames-fastapi
Project Structure
geonames-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
License
MIT License