Weather Library

These functions provide access to get current weather and 5 day forecast by longitude/latitude coordinates. If you have your own OpenWeatherMap account, you can use the OpenWeatherMap Library instead and it will use 1 Workflow Credit instead of 100.

Import


To use this library and its functions, you must use the import line at the beginning of your Base Python code.

import Weather

 

Functions

 

Weather.get_weather_by_coordinates

Usage: Weather.get_weather_by_coordinates(lat, lon)

Get current weather by geo coordinates

  • Credit cost: 100
  • Parameters:
    • latdouble latitude
    • londouble longitude
  • Returns: json

 

Weather.get_5_day_forecast_by_coordinates

Usage: Weather.get_5_day_forecast_by_coordinates(lat, lon)

Get 5 day forecast by geo coordinates

  • Credit cost: 100
  • Parameters:
    • latdouble latitude
    • londouble longitude
  • Returns: json with 5 day forecast, in 3-hour time buckets

 

Weather.get_16_day_forecast_by_coordinates

Usage: Weather.get_16_day_forecast_by_coordinates(lat, lon)

Get 16 day forecast by geo coordinates

  • Credit cost: 100
  • Parameters:
    • latdouble latitude
    • londouble longitude
  • Returns: json with 16 day forecast, in 1-day time buckets



Sample Code

import Weather
import json

lat = 37.426048
lon = -121.975243

data = Weather.get_weather_by_coordinates(lat, lon)
log(json.dumps(data))

Returns:


{
   "main":{
      "temp":292.6,
      "pressure":1010,
      "temp_max":297.15,
      "temp_min":286.48,
      "humidity":41
   },
   "clouds":{
      "all":5
   },
   "sys":{
      "country":"US",
      "sunrise":1473169384,
      "type":1,
      "message":0.0037,
      "sunset":1473215296,
      "id":480
   },
   "dt":1473130255,
   "coord":{
      "lon":-121.98,
      "lat":37.43
   },
   "weather":[
      {
         "icon":"50n",
         "description":"mist",
         "main":"Mist",
         "id":701
      }
   ],
   "name":"Alviso",
   "cod":200,
   "id":5323631,
   "base":"cmc stations",
   "wind":{
      "deg":310,
      "speed":4.1
   }
}
Have more questions? Submit a request

0 Comments

Article is closed for comments.