A caching proxy server for the Open-Meteo API that helps avoid rate limits by caching responses in Redis.
This API server acts as a transparent caching layer between your application and the Open-Meteo API. It maintains the exact same API structure as Open-Meteo, so you can use it as a drop-in replacement by simply changing the base URL.
- 🚀 Transparent Caching: Maintains exact Open-Meteo API structure
- ⚡ Redis-Backed: Fast, reliable caching with Redis
- 🔄 Configurable TTL: Set custom cache expiration times
- 🐳 Docker Ready: Complete Docker Compose setup included
- 💪 Health Checks: Built-in health monitoring
- 🔒 Rate Limit Protection: Reduce API calls through intelligent caching
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f api
# Stop services
docker-compose down# Install dependencies
npm install
# Start Redis (required)
docker run -d -p 6379:6379 redis:7-alpine
# Start the API server
npm startSimply replace the Open-Meteo API base URL with your server URL:
Before:
https://api.open-meteo.com/v1/forecast?latitude=52.52&longitude=13.41&hourly=temperature_2m
After:
http://localhost:3000/v1/forecast?latitude=52.52&longitude=13.41&hourly=temperature_2m
Configure the server using environment variables:
| Variable | Description | Default |
|---|---|---|
PORT |
API server port | 3000 |
CACHE_TTL |
Cache time-to-live (seconds) | 3600 |
REDIS_HOST |
Redis hostname | localhost |
REDIS_PORT |
Redis port | 6379 |
CACHE_TTL=7200 PORT=8080 node server.jsOr modify docker-compose.yml:
environment:
- CACHE_TTL=7200
- PORT=8080curl http://localhost:3000/healthResponse:
{
"status": "ok",
"redis": "connected"
}All Open-Meteo API endpoints are supported. Examples:
# Current weather
curl "http://localhost:3000/v1/forecast?latitude=52.52&longitude=13.41¤t=temperature_2m,wind_speed_10m"
# Hourly forecast
curl "http://localhost:3000/v1/forecast?latitude=52.52&longitude=13.41&hourly=temperature_2m,precipitation"- Request comes to the API server
- Server generates a cache key based on the endpoint and query parameters
- If cached data exists and hasn't expired, it's returned immediately (Cache HIT)
- If no cached data exists, the request is forwarded to Open-Meteo API (Cache MISS)
- Response is cached in Redis for future requests
- Response is returned to the client
# Docker Compose
docker-compose logs -f api
# Docker
docker logs -f openmeteo-cache-apiLook for:
Cache HIT- Request served from cacheCache MISS- Request forwarded to Open-Meteo APIRedis ready!- Successful Redis connection
The /health endpoint provides real-time status:
curl http://localhost:3000/health.
├── server.js # Main application
├── package.json # Dependencies
├── Dockerfile # Docker image configuration
├── docker-compose.yml # Multi-container setup
└── .github/
└── copilot-instructions.md # Copilot guidelines
- express: Web framework
- redis: Redis client for caching
- axios: HTTP client for API requests
# Check if Redis is running
docker ps | grep redis
# Test Redis connection
docker exec openmeteo-redis redis-cli pingCheck the logs for cache HIT/MISS messages:
docker-compose logs -f apiMake identical requests twice - the second should show a cache HIT.
Change the port in docker-compose.yml:
ports:
- "8080:3000" # Maps host port 8080 to container port 3000This project is provided as-is for use with the Open-Meteo API.
Contributions are welcome! Please ensure all changes:
- Follow the existing code style
- Include appropriate error handling
- Update documentation as needed
- Use Dutch for console log messages (existing convention for internal consistency)
- Connection messages: "Redis verbonden met..."
- Cache operations: "Cache HIT voor..." / "Cache MISS voor..."
- Error messages: "Te veel pogingen" / "Kan niet verbinden met..."
- Shutdown: "SIGTERM ontvangen, server wordt afgesloten..."
- Open-Meteo API for providing free weather data
- Built with Node.js, Express, and Redis