Skip to content

Instantly share code, notes, and snippets.

@joyrexus
Last active December 22, 2015 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joyrexus/6427450 to your computer and use it in GitHub Desktop.
Save joyrexus/6427450 to your computer and use it in GitHub Desktop.
Get current weather conditions via forecast.io.
# Return current weather conditions via forecast.io
req = require 'request'
key = '1b21e642bf3edf6d313f3e7ef95e3d15'
loc = '35.2102,-85.9364' # Sewanee, TN
url = "https://api.forecast.io/forecast/#{key}/#{loc}"
req url, (err, res, body) ->
data = JSON.parse body
console.log data.currently

forecast.coffee

Return current weather conditions via forecast.io.

Sample output

{ time: 1378231463,
  summary: 'Clear',
  icon: 'clear-day',
  precipIntensity: 0,
  precipProbability: 0,
  temperature: 82.3,
  apparentTemperature: 84.07,
  dewPoint: 64.92,
  windSpeed: 9.07,
  windBearing: 357,
  cloudCover: 0.19,
  humidity: 0.56,
  pressure: 1005.71,
  visibility: 10,
  ozone: 291.68 }

Source

req = require 'request'
key = '1b21e642bf3edf6d313f3e7ef95e3d15'
loc = '35.2102,-85.9364'  # Sewanee, TN
url = "https://api.forecast.io/forecast/#{key}/#{loc}"

req url, (err, res, body) -> 
  data = JSON.parse body
  console.log data.currently
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment