Hacker News new | ask | show | jobs
by gabrielsroka 1297 days ago
Using curl, jq and api.weather.gov. See docs for more info. Use Google Maps or equivalent to get lat long.

  # Set this:
 
  latlong='33.7737,-118.1365'

  url=$(curl -sS "https://api.weather.gov/points/$latlong" | jq -r '.properties.forecastHourly')
  curl -sS "$url" | jq -r '.properties | .periods[0].temperature, .generatedAt'

Using Python.

  import requests
  
  # Set this:
  latlong = '33.7737,-118.1365'
  
  session = requests.Session()
  
  url = session.get('https://api.weather.gov/points/' + latlong).json()['properties']['forecastHourly']
  f = session.get(url).json()['properties']
  print(f['periods'][0]['temperature'])
  print(f['generatedAt'])