A lightweight weather API written in Go that fetches real-time weather data from a 3rd party provider and caches it in Redis. Built as part of the Weather API Project idea from roadmap.sh.
Instead of maintaining its own weather data, the service proxies requests to the Open-Meteo API — a free provider that requires no API key. Responses are cached in Redis for 30 minutes, so repeated requests for the same city are served instantly from memory instead of hitting the external API again.
- Language: Go (standard library only —
net/http, no frameworks) - Caching: Redis (via
go-redis/v9) - External API: Open-Meteo
- Containerization: Docker & Docker Compose
- Open-Meteo integration — fetches live temperature and weather code for a city.
- Redis caching — 30-minute TTL per city, cutting down external API calls and response time.
- Configurable via environment variables —
PORTandREDIS_ADDR, ready for containerized or remote deployments. - Dockerized — runs with a single
docker compose up, no local Go or Redis install required.
Currently supported cities:
Kyiv,London,NewYork(coordinates are hardcoded — more cities and geocoding support are planned, see Roadmap).
No local Go or Redis installation needed.
git clone https://github.com/ForgottenGrom/WeatherAPI.git
cd WeatherAPI
docker compose up --buildThe API will be available at http://localhost:8080.
Prerequisites:
git clone https://github.com/ForgottenGrom/WeatherAPI.git
cd WeatherAPI
go mod tidy
# in a separate terminal, start Redis
redis-server
# run the app
go run main.goBy default it connects to localhost:6379. To point it at a different Redis instance, set REDIS_ADDR (e.g. REDIS_ADDR=my-redis-host:6379 go run main.go).
GET http://localhost:8080/?city=KyivResponse:
{
"city": "Kyiv",
"temperature": 18.2,
"description": "Clear sky"
}If the city isn't in the supported list, the API responds with 404 City not found.
- Rate limiting (per-IP, fixed window)
- Support for arbitrary cities via a geocoding lookup instead of a hardcoded list
- Stricter validation of the upstream API response
This project is part of the roadmap.sh learning platform. Issues and pull requests are welcome.
MIT