This is a .NET Core microservice that provides weather forecasts from multiple sources. The service fetches weather data from various APIs and aggregates the results.
- Fetches weather data from multiple sources:
- Weather API
- WeatherBit API
- Visual Crossing API
- Supports date validation and custom model binding
- Dockerized for easy deployment
- Unit tests with xUnit and Moq
- .NET 8.0 SDK
- Docker (for containerization)
git clone https://github.com/SerhiiYakhin/WeatherForecast.git
cd WeatherForecast
Add your API keys to the appsettings.json file:
{ "APIKeys": { "WeatherApiKey": "your-weather-api-key", "WeatherBit": "your-weatherbit-api-key", "VisualCrossing": "your-visualcrossing-api-key" } }
dotnet build
dotnet run
- Build the Docker image:
docker build -t weather-forecast . -f .\WeatherForecast\Dockerfile
- Run the Docker container:
docker run -d -p 32774:8081 -p 32775:8080 --name weather-forecast weather-forecast
- Endpoint:
/weatherforecast
- Method:
GET
- Query Parameters:
date
(required): The date for the weather forecast (supports multiple formats:yyyy-MM-dd
,dd-MM-yyyy
, etc.)- Current version support history data from 365 day ago and forecast up to 7 days ahead.
city
(required): The city for the weather forecastcountry
(required): The country for the weather forecast
curl "https://localhost:32774/weatherforecast?date=2024-01-01&city=London&country=UK"
Run the unit tests using the .NET CLI:
dotnet test