A Spring Boot web application that fetches weather updates from the OpenMeteo API.
Features
- Fetch weather by city name (uses geocoding to find coordinates)
- Fetch weather by coordinates (latitude and longitude).
- RESTful API endpoints
- JSON response format
- No API key required - OpenMeteo is free for non-commercial use!
- Java 11 or higher
- Maven 3.6 or higher (or use the included Maven wrapper)
No API key needed! OpenMeteo API is free and doesn't require authentication for non-commercial use.
export JAVA_HOME=/opt/homebrew/opt/openjdk@11 # Adjust path if needed
./mvnw spring-boot:runmvn spring-boot:run./mvnw clean package
java -jar target/weather-api-1.0.0.jarThe application will start on http://localhost:8080
Note: The first run may take a few minutes as Maven downloads dependencies.
GET http://localhost:8080/api/weather/city/{cityName}
Example:
GET http://localhost:8080/api/weather/city/London
GET http://localhost:8080/api/weather/city/New York
GET http://localhost:8080/api/weather/city/Tokyo
GET http://localhost:8080/api/weather/coordinates?lat={latitude}&lon={longitude}
Example:
GET http://localhost:8080/api/weather/coordinates?lat=51.5074&lon=-0.1278
GET http://localhost:8080/api/weather/coordinates?lat=40.7128&lon=-74.0060
GET http://localhost:8080/api/weather/health
The API returns weather information in JSON format including:
- Location coordinates (latitude, longitude)
- Current temperature
- Apparent temperature (feels like)
- Relative humidity
- Weather code
- Wind speed and direction
- Timezone information
- Elevation
{
"latitude": 51.5074,
"longitude": -0.1278,
"timezone": "Europe/London",
"current": {
"time": "2024-11-15T12:00",
"temperature_2m": 15.5,
"apparent_temperature": 14.2,
"relative_humidity_2m": 65,
"weather_code": 61,
"wind_speed_10m": 3.5,
"wind_direction_10m": 180
},
"currentUnits": {
"temperature_2m": "°C",
"wind_speed_10m": "km/h"
}
}OpenMeteo uses WMO weather codes:
- 0: Clear sky
- 1-3: Mainly clear, partly cloudy, overcast
- 45-48: Fog and depositing rime fog
- 51-67: Drizzle and rain
- 71-77: Snow
- 80-99: Rain and snow showers, thunderstorms
- Spring Boot 2.7.18
- Java 11+
- Maven
- OpenMeteo API (free, no API key required)
✅ This project is completely free to use and share on GitHub!
- Free Tier: Up to 10,000 API calls per day
- No API Key Required: Works out of the box
- Non-Commercial Use: Free for personal projects, learning, and open source
- Commercial Use: Requires a paid subscription (see OpenMeteo Pricing)
Yes! This project is free to:
- ✅ Push to GitHub (public or private repositories)
- ✅ Use for personal projects
- ✅ Use for educational purposes
- ✅ Share with others
- ✅ Contribute to open source
Note: If you plan to use this commercially (making money from it), you'll need to upgrade to a paid OpenMeteo plan.
This project uses the OpenMeteo API which is free for non-commercial use. Please refer to OpenMeteo Terms of Service for commercial usage.
You can license your code however you want (MIT, Apache, etc.). The OpenMeteo API usage is free for non-commercial projects.