A simple weather API built with Go, using the Echo web framework. This project demonstrates how to build a RESTful API that fetches weather data from external sources and serves it to clients, with caching support.
- Fetches weather data from the Open-Meteo API
- RESTful endpoints for weather information
- In-memory TTL cache for improved performance
- Dockerized for easy deployment
.
├── cmd/server/ # Main entrypoint for the API server
├── internal/openmeteo/ # Open-Meteo API client
├── internal/weather/ # Weather handler and types
├── pkg/cache/ # TTL cache implementation
├── Dockerfile # Multi-stage Docker build
├── docker-compose.yml # Docker Compose setup
├── go.mod, go.sum # Go modules
└── README.md
- Go 1.24+
- Docker (optional, for containerized deployment)
First, copy the example environment file:
cp .env.example .envThen run the server:
go run ./cmd/serverThe API will be available at http://localhost:8080.
Build and run with Docker Compose:
docker-compose up --buildGET /weather?lat=<latitude>&lon=<longitude>&units=metric: Get current weather for a location
- The server listens on port
8080by default (configurable via thePORTenvironment variable in .env file).
MIT