WeatherAPI is a RESTful ASP.NET Core Web API that provides comprehensive weather data by integrating with WeatherAPI.com. It offers endpoints for current weather, forecasts, historical data, marine weather, astronomy, time zone, sports events, and more. The API is designed for easy integration with web, mobile, and desktop applications.
- Get current weather for any location
- 1-14 day weather forecasts
- Historical weather data
- Marine weather information
- Astronomy details (sunrise, sunset, moon phase, etc.)
- Time zone and location info
- Sports events by location
- Weather alerts
- IP-based weather lookup
- Location search and autocomplete
All endpoints are prefixed with /api/weather
(e.g., /api/weather/current
).
Endpoint | Method | Description | Parameters |
---|---|---|---|
/current | GET | Get current weather | q (location query) |
/forecast | GET | Get weather forecast | q (location), days (1-14) |
/history | GET | Get historical weather | q (location), dt (yyyy-MM-dd) |
/alerts | GET | Get weather alerts | q (location) |
/marine | GET | Get marine weather | q (location) |
/future | GET | Get future weather | q (location), dt (yyyy-MM-dd) |
/search | GET | Search or autocomplete location | q (location) |
/iplookup | GET | IP lookup for weather and location info | q (IP address or 'auto:ip') |
/astronomy | GET | Get astronomy info | q (location), dt (yyyy-MM-dd) |
/timezone | GET | Get time zone info | q (location) |
/sports | GET | Get sports events | q (location) |
GET /api/weather/current?q=London
- Clone the repository:
git clone https://github.com/apayadfullscale-dev/WeatherAPI.git cd WeatherAPI
- Restore dependencies:
dotnet restore
- Build the project:
dotnet build
- Run the API:
dotnet run
- Access Swagger UI at
http://localhost:5000/swagger
(or the port shown in your terminal).
Set your WeatherAPI.com API key in appsettings.json
:
{
"WeatherApi": {
"ApiKey": "YOUR_API_KEY"
}
}
- ASP.NET Core 9
- C#
- WeatherAPI.com
- Swashbuckle (Swagger)
This project is licensed under the MIT License.