A RESTful API service that provides real-time wave, weather, and tide predictions by integrating NOAA's Global Forecast System (GFS) and NDBC buoy data. Built with Python and Flask, this API delivers accurate surf forecasting data with efficient caching and comprehensive error handling.
- Wave Forecasts: Real-time wave height calculations, swell analysis, and breaking wave predictions
- Weather Integration: NOAA GFS data processing for detailed weather forecasting
- Buoy Data: Live and historical data from NDBC buoys
- Tide Predictions: Accurate tide forecasting using NOAA tide stations
- Performance Optimized: Redis caching and rate limiting
- Error Handling: Comprehensive validation and error management
- Documentation: Detailed API documentation and examples
GET /api/forecast/location| Parameter | Type | Description |
|---|---|---|
lat |
float | Latitude (-90 to 90) |
lon |
float | Longitude (-180 to 180) |
depth |
float | Water depth in meters (default: 30) |
angle |
float | Beach angle in degrees (default: 145) |
slope |
float | Beach slope (default: 0.02) |
hours |
int | Forecast hours (1-384, default: 24) |
GET /api/buoys/location| Parameter | Type | Description |
|---|---|---|
lat |
float | Latitude (-90 to 90) |
lon |
float | Longitude (-180 to 180) |
count |
int | Number of buoys to return (1-10, default: 5) |
active |
bool | Filter for active buoys (default: true) |
type |
string | Buoy type (buoy, fixed, etc.) |
GET /api/buoys/{station_id}/dataGET /api/tides/location| Parameter | Type | Description |
|---|---|---|
lat |
float | Latitude (-90 to 90) |
lon |
float | Longitude (-180 to 180) |
days |
int | Days to forecast (default: 3) |
- Backend: Python, Flask
- Data Processing: NumPy, pygrib, netCDF4
- Caching: Redis
- API Features: Rate limiting, CORS support
- Data Sources: NOAA GFS, NDBC Buoys, NOAA Tides & Currents
Clone the repository:
git clone https://github.com/yourusername/wave-forecasting-api.git
cd wave-forecasting-apiInstall dependencies:
pip install -r requirements.txtSet up environment variables:
cp .env.example .env
# Edit .env with your configurationRun the development server:
python run.pyBuild and run with Docker:
# Build the image
docker build -t wave-forecasting-api .
# Run the container
docker run -d -p 5000:5000 wave-forecasting-apicurl "http://localhost:5000/api/forecast/location?lat=41.35&lon=-71.4"Example response:
{
"forecasts": [
{
"timestamp": "2024-11-07T12:00:00+00:00",
"wave_summary": {
"height": 1.92,
"period": 6.40,
"direction": 180.64,
"compass_direction": "S",
"steepness": "STEEP"
},
"breaking_waves": {
"maximum_height": 2.16,
"minimum_height": 1.54
},
"swells": [
{
"height": 1.88,
"period": 6.40,
"direction": 177.79,
"compass_direction": "S"
}
],
"wind": {
"speed": 4.38,
"direction": 294.14,
"compass_direction": "WNW"
}
}
],
"location": {
"latitude": 41.35,
"longitude": -71.4,
"depth": 30.0,
"angle": 145.0,
"slope": 0.02
}
}curl "http://localhost:5000/api/buoys/location?lat=41.35&lon=-71.4&count=3"curl "http://localhost:5000/api/buoys/44097/data"FLASK_ENV=development
FLASK_APP=run.py
REDIS_URL=redis://localhost:6379
CACHE_TIMEOUT=300
RATE_LIMIT_PER_MINUTE=60Requirements:
- Python 3.9+
- Redis server for caching
- Environment variables configured
The API provides detailed error responses:
{
"error": "Invalid parameters",
"details": "Latitude must be between -90 and 90",
"timestamp": "2024-11-07T12:00:00Z"
}Common HTTP status codes:
200: Success400: Bad Request404: Not Found429: Too Many Requests500: Server Error
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- NOAA for providing GFS and buoy data
- NDBC for buoy station information
- Weather data processing libraries contributors