Simple Weather API

made-with-go
go 1.17
windows terminal
vscode

Simple weather api app created using golang and Open Weather API key

Installation :-

Verify golang installation in your computer by typing 👇

go version

Then change the directory to the cloned directory folder 👇

cd <cloned directory path>

To install all requirement packages for the app 👇

go install

Create a new file .apiconfig and insert your Open Weather API key like this 👇

{
    "OpenWeatherMapApiKey" : "<Your API key>"
}

Then, Run the app 👇

go run main.go

Open your browser and search 👇

http://localhost:8080/weather/<location>

Or Try to use curl commandLine tool 👇

curl http://localhost:8080/weather/<location>

Sample Output :-

JSON File

{
  "coord": {
    "lon": 80.2785,
    "lat": 13.0878
  },
  "weather": [
    {
      "id": 802,
      "main": "Clouds",
      "description": "scattered clouds",
      "icon": "03d"
    }
  ],
  "base": "stations",
  "main": {
    "temp": 303.14,
    "pressure": 1009,
    "humidity": 74,
    "temp_min": 303.14,
    "temp_max": 303.14
  },
  "visibility": 6000,
  "wind": {
    "speed": 4.12,
    "deg": 130
  },
  "rain": {
    "1h": 0
  },
  "clouds": {
    "all": 40
  },
  "dt": 1644052629,
  "sys": {
    "type": 1,
    "id": 9218,
    "message": 0,
    "country": "IN",
    "sunrise": 1644023076,
    "sunset": 1644064867
  },
  "id": 1264527,
  "name": "Chennai",
  "cod": 200
}

📷 Demo GIF Image :-

demo_gif

GitHub

View Github