Skip to content

engripaye/weather-api-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

76 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation


🌦️ Weather API Wrapper

Weather API Wrapper Dashboard

A simple and professional Weather API Wrapper built with FastAPI, SQLite, and httpx. This project fetches weather data from the free Open-Meteo API and stores query history locally.

Weather API Wrapper Flowchart

⚑ Features

  • Fetch current weather by city 🌍
  • Fetch current weather by GPS coordinates πŸ“
  • Fetch 5-day forecast for a city πŸ“…
  • Store weather history in SQLite πŸ—„οΈ
  • Retrieve all history records πŸ“–
  • Delete history records ❌
  • List all unique cities queried πŸ™οΈ

πŸ› οΈ Tech Stack

  • FastAPI – Web framework
  • httpx – Async HTTP client for API calls
  • SQLite + SQLAlchemy – Database & ORM
  • Pydantic – Data validation

πŸ“¦ Installation

# Clone repo git clone https://github.com/your-username/weather-api-wrapper.git cd weather-api-wrapper # Create virtual environment python -m venv venv source venv/bin/activate # Linux/Mac venv\Scripts\activate # Windows # Install dependencies pip install -r requirements.txt # Run server uvicorn main:app --reload

πŸ”— API Endpoints

1. Health Check

GET /ping

βœ… Response:

{ "message": "pong" }

2. Get Current Weather by City

GET /weather/{city}

βœ… Example:

GET /weather/Lagos

Response:

{ "id": 1, "city": "Lagos", "temperature": 29.5, "description": "Partly cloudy", "timestamp": "2025-09-05T17:50:23" }

3. Get Current Weather by Coordinates

GET /weather/coordinates?lat={lat}&lon={lon}

βœ… Example:

GET /weather/coordinates?lat=6.5244&lon=3.3792

Response:

{ "id": 2, "city": "(6.5244,3.3792)", "temperature": 29.0, "description": "Clear sky", "timestamp": "2025-09-05T17:55:42" }

4. Get 5-Day Forecast

GET /forecast/{city}?days=5

βœ… Example:

GET /forecast/London?days=5

Response:

{ "city": "London", "daily": { "temperature_2m_max": [23.5, 22.1, 21.7, 24.0, 25.3], "temperature_2m_min": [15.2, 14.8, 14.5, 15.0, 16.3] } }

5. Get Weather History

GET /history

βœ… Response:

[ { "id": 1, "city": "Lagos", "temperature": 29.5, "description": "Partly cloudy", "timestamp": "2025-09-05T17:50:23" }, { "id": 2, "city": "(6.5244,3.3792)", "temperature": 29.0, "description": "Clear sky", "timestamp": "2025-09-05T17:55:42" } ]

6. Delete History Record

DELETE /history/{id}

βœ… Example:

DELETE /history/2

Response:

{ "message": "Record 2 deleted" }

7. List All Queried Cities

GET /cities

βœ… Response:

{ "cities": ["Lagos", "London", "(6.5244,3.3792)"] }

πŸ§ͺ Testing with Postman

  • Import the endpoints above into Postman

  • Start the server with:

    uvicorn main:app --reload
  • Test endpoints like:

    • http://127.0.0.1:8000/weather/Lagos
    • http://127.0.0.1:8000/forecast/London?days=3

πŸš€ Future Improvements

  • Add caching with Redis for faster repeated lookups
  • Add user authentication with JWT tokens
  • Build a React frontend for visualizing weather

πŸ“„ License

MIT License. Free to use and modify.



πŸ‘€ Author

Ipaye Babatunde


About

🌦️ Professional Weather API Wrapper Application built with FastAPI. fetches live weather data from the free [Open-Meteo API](https://open-meteo.com/), stores query history in SQLite, and returns results in a clean JSON format.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors