Welcome to IntelliWeather v3.0! This guide will help you get started with the new enterprise-grade features.
# 1. Clone and navigate to project
cd /workspaces/Weather-API
# 2. Install dependencies
pip install -r requirements.txt
# 3. Configure environment (optional)
cp .env.example .env
# Edit .env if you have API keys
# 4. Start the server
uvicorn app:app --reload --host 0.0.0.0 --port 8000# Start all services
docker-compose up -d
# View logs
docker-compose logs -f app
# Stop services
docker-compose down# Get 15-minute interval forecast for New York
curl "http://localhost:8000/api/v3/forecast/nowcast?latitude=40.7128&longitude=-74.0060" | jq
# Response includes:
# - 15-minute intervals for next 2 hours
# - Temperature, precipitation, wind
# - Weather codes# Get 48-hour forecast
curl "http://localhost:8000/api/v3/forecast/hourly?latitude=40.7128&longitude=-74.0060&hours=48" | jq
# Get 7-day hourly with hybrid data
curl "http://localhost:8000/api/v3/forecast/hourly?latitude=40.7128&longitude=-74.0060&hours=168&hybrid=true" | jq# Get 16-day forecast
curl "http://localhost:8000/api/v3/forecast/daily?latitude=40.7128&longitude=-74.0060&days=16" | jq# All-in-one: Nowcast + Hourly + Daily
curl "http://localhost:8000/api/v3/forecast/complete?latitude=40.7128&longitude=-74.0060" | jq# Get all calculated insights
curl "http://localhost:8000/api/v3/insights/current?latitude=40.7128&longitude=-74.0060" | jq
# Specific insights
curl "http://localhost:8000/api/v3/insights/fire-risk?latitude=34.0522&longitude=-118.2437&days_since_rain=7" | jq
curl "http://localhost:8000/api/v3/insights/uv-exposure?latitude=25.7617&longitude=-80.1918" | jq
curl "http://localhost:8000/api/v3/insights/travel-disruption?latitude=51.5074&longitude=-0.1278" | jq
curl "http://localhost:8000/api/v3/insights/comfort?latitude=28.6139&longitude=77.2090" | jq
curl "http://localhost:8000/api/v3/insights/feels-like?latitude=35.6762&longitude=139.6503" | jq# Autocomplete search
curl "http://localhost:8000/geocode/autocomplete?q=New%20Yo&limit=5" | jq
# Popular locations
curl "http://localhost:8000/geocode/popular?limit=20" | jq
# Nearby cities (within 100km)
curl "http://localhost:8000/geocode/nearby?lat=40.7128&lon=-74.0060&radius_km=100&limit=10" | jqOnce the server is running:
Interactive API Explorer:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Health Check:
curl http://localhost:8000/healthMetrics:
curl http://localhost:8000/metricsIf you want to use API key authentication:
- Create an account:
curl -X POST "http://localhost:8000/auth/signup" \
-H "Content-Type: application/json" \
-d '{
"email": "your@email.com",
"password": "securepassword",
"full_name": "Your Name"
}'- Login:
curl -X POST "http://localhost:8000/auth/login" \
-H "Content-Type: application/json" \
-d '{
"email": "your@email.com",
"password": "securepassword"
}' \
-c cookies.txt- Create API key:
curl -X POST "http://localhost:8000/apikeys" \
-H "Content-Type: application/json" \
-b cookies.txt \
-d '{
"name": "My App Key",
"rate_limit_per_minute": 100
}'- Use API key:
curl "http://localhost:8000/api/v3/forecast/nowcast?latitude=40.7128&longitude=-74.0060" \
-H "X-API-Key: your-api-key-here"#!/bin/bash
# Monitor fire risk for California
LOCATIONS=(
"34.0522,-118.2437,Los Angeles"
"37.7749,-122.4194,San Francisco"
"32.7157,-117.1611,San Diego"
)
for loc in "${LOCATIONS[@]}"; do
IFS=',' read -r lat lon name <<< "$loc"
echo "=== Fire Risk for $name ==="
curl -s "http://localhost:8000/api/v3/insights/fire-risk?latitude=$lat&longitude=$lon&days_since_rain=10" \
| jq '{
location: "'$name'",
score: .fire_risk.score,
category: .fire_risk.category,
recommendation: .fire_risk.recommendation
}'
echo ""
done#!/bin/bash
# Check conditions for outdoor event
LAT=40.7128
LON=-74.0060
echo "=== Event Weather Assessment ==="
# Get complete forecast
echo "1. Complete Forecast:"
curl -s "http://localhost:8000/api/v3/forecast/complete?latitude=$LAT&longitude=$LON" \
| jq '{
nowcast: .nowcast.time[0:4],
hourly_temps: .hourly.temperature_2m[0:24],
daily_summary: .daily.temperature_2m_max[0:3]
}'
# Get comfort index
echo -e "\n2. Comfort Assessment:"
curl -s "http://localhost:8000/api/v3/insights/comfort?latitude=$LAT&longitude=$LON" \
| jq '.comfort'
# Get UV exposure
echo -e "\n3. UV Risk:"
curl -s "http://localhost:8000/api/v3/insights/uv-exposure?latitude=$LAT&longitude=$LON" \
| jq '.uv_exposure'
# Get travel conditions
echo -e "\n4. Travel Conditions:"
curl -s "http://localhost:8000/api/v3/insights/travel-disruption?latitude=$LAT&longitude=$LON" \
| jq '.travel_disruption'import requests
import json
BASE_URL = "http://localhost:8000"
def search_and_forecast(query):
"""Search for location and get forecast."""
# 1. Autocomplete search
print(f"Searching for: {query}")
autocomplete_resp = requests.get(
f"{BASE_URL}/geocode/autocomplete",
params={"q": query, "limit": 3}
)
suggestions = autocomplete_resp.json()["suggestions"]
if not suggestions:
print("No locations found")
return
# 2. Select first result
location = suggestions[0]
print(f"\nSelected: {location['display_name']}")
print(f"Coordinates: {location['latitude']}, {location['longitude']}")
# 3. Get complete forecast
forecast_resp = requests.get(
f"{BASE_URL}/api/v3/forecast/complete",
params={
"latitude": location['latitude'],
"longitude": location['longitude']
}
)
forecast = forecast_resp.json()
# 4. Get insights
insights_resp = requests.get(
f"{BASE_URL}/api/v3/insights/current",
params={
"latitude": location['latitude'],
"longitude": location['longitude']
}
)
insights = insights_resp.json()
# 5. Display results
print("\n=== FORECAST SUMMARY ===")
print(f"Timezone: {forecast['timezone']}")
if forecast.get('nowcast'):
print(f"\nNowcast (next 2 hours):")
print(f" Intervals: {len(forecast['nowcast'].get('time', []))}")
if forecast.get('hourly'):
temps = forecast['hourly'].get('temperature_2m', [])[:24]
print(f"\n24-Hour Temps: {temps[0]:.1f}Β°C - {max(temps):.1f}Β°C")
print("\n=== INSIGHTS ===")
if 'insights' in insights and insights['insights']:
for key, value in insights['insights'].items():
print(f"{key}: {value}")
# Example usage
search_and_forecast("London")Create a .env file:
# Application
APP_NAME=IntelliWeather
APP_VERSION=3.0.0
DEBUG=false
# External APIs
WEATHERAPI_KEY=your_weatherapi_key_here
ENABLE_FALLBACK=true
# Caching
CACHE_TTL_SECONDS=3600
CACHE_MAX_SIZE=1000
# Rate Limiting
RATE_LIMIT_PER_MIN=60
# Popular Locations (customize for your region)
POPULAR_LOCATIONS=40.7128,-74.0060,New York;51.5074,-0.1278,London;35.6762,139.6503,Tokyo
# Phase 3 Features (all enabled by default)
FEATURE_NOWCAST=true
FEATURE_EXTENDED_HOURLY=true
FEATURE_EXTENDED_DAILY=true
FEATURE_HYBRID_FORECAST=true
FEATURE_HEAT_INDEX=true
FEATURE_FIRE_RISK=true
FEATURE_UV_EXPOSURE=true
FEATURE_TRAVEL_DISRUPTION=true
FEATURE_AUTOCOMPLETE=true# First request (cache miss) - slower
time curl "http://localhost:8000/api/v3/forecast/hourly?latitude=40.7128&longitude=-74.0060"
# Second request (cache hit) - much faster!
time curl "http://localhost:8000/api/v3/forecast/hourly?latitude=40.7128&longitude=-74.0060"# Instead of 3 separate calls:
# /nowcast + /hourly + /daily
# Use single call:
curl "http://localhost:8000/api/v3/forecast/complete?latitude=40.7128&longitude=-74.0060"# Check Prometheus metrics
curl http://localhost:8000/metrics | grep cache_hits
curl http://localhost:8000/metrics | grep cache_missesSolution: Check if Open-Meteo API is accessible:
curl "https://api.open-meteo.com/v1/forecast?latitude=40.7128&longitude=-74.0060¤t=temperature_2m"Solution: Verify geocoding API:
curl "https://geocoding-api.open-meteo.com/v1/search?name=London"Solution: Check WeatherAPI key in .env:
WEATHERAPI_KEY=your_valid_key_here
ENABLE_FALLBACK=trueSolution:
- Check cache hit ratio in metrics
- Increase
CACHE_MAX_SIZEin config - Enable Redis for production caching
- Explore the full API at http://localhost:8000/docs
- Read
PHASE3_README.mdfor detailed documentation - Check
ARCHITECTURE.mdfor system design - Review test files in
tests/
- Set up Redis for distributed caching
- Configure PostgreSQL for persistent storage
- Enable Sentry for error tracking
- Set up Nginx reverse proxy
- Deploy with Docker Compose or Kubernetes
- Implement LEVEL 2 features (Pollen, Marine, Solar APIs)
- Create developer SDKs (Python, JavaScript)
- Add developer dashboard
- Implement PostgreSQL migration
- API Documentation: http://localhost:8000/docs
- Phase 3 Features:
PHASE3_README.md - Architecture:
ARCHITECTURE.md - Changelog:
CHANGELOG.md - Roadmap:
future_build.md
Found a bug or have a question?
- Check the API docs first
- Review troubleshooting section
- Check existing issues in the repo
Happy coding! π
Built with β€οΈ for enterprise-grade weather intelligence