https://github.com/santura-dev/weather-api
This project is a Flask-based weather API that provides real-time weather, forecast, and historical data for cities worldwide. It fetches data from the Visual Crossing API, uses Redis for caching to improve performance, and integrates Flask’s rate limiter to control request frequency and prevent misuse.
https://github.com/santura-dev/weather-api
api flask redis redis-cache weather weather-api weather-app weather-data weather-forecast weather-information weatherapp
Last synced: about 2 months ago
JSON representation
This project is a Flask-based weather API that provides real-time weather, forecast, and historical data for cities worldwide. It fetches data from the Visual Crossing API, uses Redis for caching to improve performance, and integrates Flask’s rate limiter to control request frequency and prevent misuse.
- Host: GitHub
- URL: https://github.com/santura-dev/weather-api
- Owner: santura-dev
- License: mit
- Created: 2025-02-16T16:57:48.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-05-31T09:27:42.000Z (about 1 year ago)
- Last Synced: 2026-04-30T19:36:29.383Z (2 months ago)
- Topics: api, flask, redis, redis-cache, weather, weather-api, weather-app, weather-data, weather-forecast, weather-information, weatherapp
- Language: HTML
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Weather API Project
This project is a weather API service built using Flask that provides weather data based on city inputs. The application fetches data from the Visual Crossing API and caches it using Redis. It includes a rate limiter to avoid abuse and offers multiple endpoints for different types of weather and air quality data.
## Features
- Current weather data for any city.
- Weather data for a custom date range.
- Air quality data for any city.
- Redis caching for improved performance.
- Flask rate limiting for API requests.
## Installation
### 1. Clone the Repository
```bash
git clone https://github.com/RavenLB/Weather-API.git
cd weather-API
```
### 2. Install Required Dependencies
Create a virtual environment and install the dependencies:
```bash
python -m venv venv
source venv/bin/activate # For macOS/Linux
venv\Scriptsctivate # For Windows
pip install -r requirements.txt
```
### 3. Set Up Environment Variables
Create a `.env` file in the root directory and add your API key for Visual Crossing API and Redis configuration:
```bash
WEATHER_API_KEY=your_api_key_here
WEATHER_URL=visual_crossing_url
REDIS_HOST=localhost
REDIS_PORT=your_redis_port
```
### 4. Run the Application
Start the Flask application:
```bash
flask run
```
The app will be available at `http://127.0.0.1:5000`.
## API Endpoints
### 1. **Get Current Weather**
**URL:** `/weather/current/`
**Path Parameters:**
- `city`: The name of the city (required).
Example:
```bash
http://127.0.0.1:5000/weather/current/Amsterdam
```
### 2. **Get Weather Forecast**
**URL:** `/weather/forecast//`
**Path Parameters:**
- `city`: The name of the city (required).
- `days`: Number of days in the future to forecast (1-15, required).
Example:
```bash
http://127.0.0.1:5000/weather/forecast/Amsterdam/7
```
### 3. **Get Historical Weather**
**URL:** `/weather/historical///`
**Path Parameters:**
- `city`: The name of the city (required).
- `start`: Start date of the range (required, format: YYYY-MM-DD).
- `end`: End date of the range (required, format: YYYY-MM-DD).
Example:
```bash
http://127.0.0.1:5000/weather/historical/Amsterdam/2023-01-01/2023-01-07
```
## Technologies Used
- Python
- Flask
- Redis
- Visual Crossing API
- Flask Limiter
## Contributing
Feel free to fork the repository, submit issues, or create pull requests.
## License
This project is licensed under the MIT License.