Skip to content

Instantly share code, notes, and snippets.

@stevelippert
Created May 12, 2014 00:58
Show Gist options
  • Select an option

  • Save stevelippert/a2091bf6d0d84e93df9f to your computer and use it in GitHub Desktop.

Select an option

Save stevelippert/a2091bf6d0d84e93df9f to your computer and use it in GitHub Desktop.
WeatherSTEM API Example in Ruby
#!/usr/bin/env ruby
require 'uri'
require 'json'
require 'net/http'
require 'net/https'
uri = URI.parse("https://leonschools.weatherstem.com/api")
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
@vars = {
"api_key" => "cs9ynb6t",
"stations" => ["canopyoaks"]
}.to_json
req = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' => 'application/json'})
req.body = @vars
response = https.request(req)
puts "Response #{response.code} #{response.message}: #{response.body}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment