Skip to content

Instantly share code, notes, and snippets.

@RBangel
Created April 18, 2014 20:40
Show Gist options
  • Select an option

  • Save RBangel/11063436 to your computer and use it in GitHub Desktop.

Select an option

Save RBangel/11063436 to your computer and use it in GitHub Desktop.
(ns wunderground.core
(:require [clj-http.client :as client])
(:require [clojure.data.json :as json]))
(def APIKey "key")
(def WStation "KALMADIS1")
; (def Feature "/conditions")
(def Feature "/history_20140418")
(def Wurl (str "http://api.wunderground.com/api/"
APIKey
Feature
"/q/pws:"
WStation
".json"))
(def ResultSet (client/get Wurl { :accept :json }))
(defn rbody [response]
(json/read-str (get response :body) :key-fn keyword))
(defn rfeat [response]
(get (rbody response) :current_observation))
(println (keys (rbody ResultSet)))
(println (take-nth 2 (rbody ResultSet)))
(println (rfeat ResultSet))
(println (keys (get (rbody ResultSet) :current_observation)))
(println (get-in (rbody ResultSet) [:current_observation :temp_f]))
(keys (get (rbody ResultSet) :history))
(def obs (get-in (rbody ResultSet) [:history :observations]))
(keys (first obs))
(map #(get %1 :precip_totali) obs )
(count obs)
(map #(get-in %1 [:date :pretty]) obs )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment