Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌤️ Weather API Service

Go Version Docker License

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.

Overview

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.

Tech Stack

  • Language: Go (standard library only — net/http, no frameworks)
  • Caching: Redis (via go-redis/v9)
  • External API: Open-Meteo
  • Containerization: Docker & Docker Compose

Features

  • 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 variablesPORT and REDIS_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).

Getting Started

Option A — Docker (recommended)

No local Go or Redis installation needed.

git clone https://github.com/ForgottenGrom/WeatherAPI.git
cd WeatherAPI
docker compose up --build

The API will be available at http://localhost:8080.

Option B — Manual

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.go

By 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).

Usage Example

GET http://localhost:8080/?city=Kyiv

Response:

{
  "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.

Roadmap

  • 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

Contributing

This project is part of the roadmap.sh learning platform. Issues and pull requests are welcome.

License

MIT

About

My first pet-project

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages