A simple REST API built with Go that provides weather information based on city names.
- REST endpoint to get weather by city name
- Swagger UI documentation
- Simple and clean architecture
- Go 1.16 or higher
- Internet connection for downloading dependencies
-
Clone the repository:
git clone <repository-url> cd weather-api
-
Install dependencies:
go mod download
-
Generate Swagger documentation:
go install github.com/swaggo/swag/cmd/swag@latest swag init
Start the server:
go run main.go
The server will start on port 8080.
GET /api/v1/weather?city=London
Example response:
{
"city": "London",
"temperature": 15.5,
"condition": "Cloudy",
"humidity": 70,
"wind_speed": 5.2
}
Access the Swagger UI at:
http://localhost:8080/swagger/index.html
This is a demonstration API that simulates weather data. In a production environment, you would integrate with a real weather data provider like OpenWeatherMap, AccuWeather, etc.
MIT