Skip to content

StevenMartinez94/weather-api

Repository files navigation

Weather API

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.

Features

  • Fetches weather data from the Open-Meteo API
  • RESTful endpoints for weather information
  • In-memory TTL cache for improved performance
  • Dockerized for easy deployment

Project Structure

.
├── 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

Getting Started

Prerequisites

  • Go 1.24+
  • Docker (optional, for containerized deployment)

Running Locally

First, copy the example environment file:

cp .env.example .env

Then run the server:

go run ./cmd/server

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

Using Docker

Build and run with Docker Compose:

docker-compose up --build

Test API Endpoint

  • GET /weather?lat=<latitude>&lon=<longitude>&units=metric: Get current weather for a location

Configuration

  • The server listens on port 8080 by default (configurable via the PORT environment variable in .env file).

License

MIT

About

A lightweight Go + Echo REST API for practicing purposes, fetching and serving current weather data from the Open-Meteo API with caching and docker-compose.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors