Skip to content

varvarvarvar/weather_forecast_bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

weather_forecast_bot

With this API you can get current weather forecast for different locations all over the world.

API description

GET request to https://varvara-weather-forecast-bot.herokuapp.com/weather/api/v1.0/

Parameters:

location (str): Location

Returns:

{
location (str or None): Location
response (str or None): Verbal weather description
error (str, optional): Error description
}

Command line usage examples

$ curl -i -H "Content-Type: application/json" -X GET -d '{"location": "Red Square"}' https://varvara-weather-forecast-bot.herokuapp.com/weather/api/v1.0/
>> {"location":"Red Square","response":"Temperature: 13C, feels like: 12C, rain."}
$ curl -i -H "Content-Type: application/json" -X GET -d '{"location": "Natural History Museum, London"}' https://varvara-weather-forecast-bot.herokuapp.com/weather/api/v1.0/
>> {"location":"Natural History Museum, London","response":"Temperature: 20C, feels like: 21C, cloudy."}
$ curl -i -H "Content-Type: application/json" -X GET -d '{"location": "Piazza del Colosseo, 1, Roma"}' https://varvara-weather-forecast-bot.herokuapp.com/weather/api/v1.0/
>> {"location":"Piazza del Colosseo, 1, Roma","response":"Temperature: 26C, feels like: 28C, clear."}
$ curl -i -H "Content-Type: application/json" -X GET -d '{"location": "хупся"}' https://varvara-weather-forecast-bot.herokuapp.com/weather/api/v1.0/
>> {"error": "Error parsing location 'хупся' with geopy.", "location": "хупся", "response": null}

Used technology stack

  1. Yandex Weather API: API with detailed weather info based on latitude and longitude
  2. geopy: Python library to convert string address to its latitude and longitude
  3. Flask API: Web application framework
  4. Docker: Tool for building containerized applications
  5. Heroku server: Cloud server platform
  6. Moesif: API Monitoring

Useful tutorials

  1. Guide to RESTful API with Flask
  2. Guide to Deploying a Flask app on Heroku
  3. Yandex Weather API Examples
  4. Heroku Port Binding

TODO

  1. Pre commit hooks
  2. Prometheus
  3. Grafana