Forecasts Example with Fields


    from aerisweather.aerisweather import AerisWeather
    from aerisweather.requests.ParameterType import ParameterType
    from aerisweather.requests.RequestLocation import RequestLocation
    from aerisweather.requests.RequestAction import RequestAction
    from aerisweather.requests.RequestFilter import RequestFilter
    from keys import client_id, client_secret, app_id

    # instantiate our aerisweather object
    aeris = AerisWeather(client_id=client_id, client_secret=client_secret, app_id=app_id)

    # Let's create a new RequestLocation, this time using a postal code
    loc = RequestLocation(postal_code="55124")

    # we'll limit the fields returned by the API too, to just the ones we need for our example
    forecast_list = aeris.forecasts(location=loc,
                                    params={ParameterType.FORECASTS.FIELDS: "periods.isDay, periods.maxTempF, periods.minTempF,"})

    for forecast in forecast_list:
        # check to see if this is a day or night forecast
        if forecast.periods[0].isDay:
            day = forecast.periods[0]
            night = forecast.periods[1]
            day = forecast.periods[1]
            night = forecast.periods[0]
        print("Forecast Example:")
        print("Today expect " + + " with a high temp of " + str(day.maxTempF) + "°")
        print("Tonight will be " + + " with a low temp of " + str(night.minTempF) + "°")

Expected output:

Forecast Example:
Today expect Partly Cloudy with a high temp of 66°
Tonight will be Partly Cloudy with Light Showers Likely with a low temp of 48°


*The actual values may vary